Improved comments

This commit is contained in:
fatalerrors
2021-09-06 14:40:35 +02:00
parent 9f584fcd65
commit 66daa05175
5 changed files with 47 additions and 3 deletions

View File

@@ -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()
{