Improved comments
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
# https://opensource.org/licenses/BSD-3-Clause
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Exit with error
|
||||
function die()
|
||||
{
|
||||
@@ -27,6 +29,8 @@ function die()
|
||||
}
|
||||
export -f die
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
function terminate()
|
||||
{
|
||||
prnt E "$1 reçu, sortie immédiate."
|
||||
@@ -35,6 +39,9 @@ function terminate()
|
||||
trap "terminate 'Ctrl + C'" SIGINT
|
||||
trap "terminate 'SIGTERM'" SIGTERM
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Function triggered on error
|
||||
function error()
|
||||
{
|
||||
local parent_lineno="$1"
|
||||
@@ -52,10 +59,11 @@ function error()
|
||||
fi
|
||||
#awk 'NR>L-4 && NR<L+4 { printf "%-5d%3s%s\n",NR,(NR==L?">>>":""),$0 }' L=$1 $0
|
||||
}
|
||||
|
||||
# Trigger error function on error
|
||||
trap "error ${LINENO}; backtrace; exit 255" ERR
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Print a backtrace
|
||||
function backtrace
|
||||
{
|
||||
@@ -70,6 +78,8 @@ function backtrace
|
||||
echo "=============================="
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Test and exit if not root (or any UID 0 user)
|
||||
check_root()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user