libs: made error message clearer and more consistent

This commit is contained in:
levasseur
2021-12-13 18:49:03 +01:00
parent bbd35ee3c6
commit d9af921417
6 changed files with 17 additions and 12 deletions

View File

@@ -134,7 +134,7 @@ check_root()
return 0
fi
if [[ $EUID -ne 0 ]]; then
prnt E "That script must be run with root privileges."
prnt E "check_root: That script must be run with root privileges."
die 4 --force
fi
}

View File

@@ -177,7 +177,7 @@ patchfile()
local workfile=${dstfile}.work
if [[ ! -s $srcfile ]]; then
prnt E "The source file is empty, is not a file or don't exists!"
prnt E "patchfile(): Source file is empty, is not a file or don't exists!"
die 10
fi
@@ -218,7 +218,7 @@ file_exists()
prnt I "Checking $@ files existance..."
for f in $@; do
if [[ ! -f $(select_file $f) ]]; then
prnt E "The $f file is missing, cannot continue."
prnt E "file_exists(): The $f file is missing, can't continue."
die 10
fi
done

View File

@@ -15,7 +15,7 @@
exec_serv()
{
if [[ $# -lt 2 ]]; then
prnt E "exec_serv(): Syntax error!"
prnt E "exec_serv(): Syntax error (parameters: $@)!"
exit 11
fi

View File

@@ -21,6 +21,11 @@ export -f stdtime
# ------------------------------------------------------------------------------
# Check if a function exists, return 0 if so
function_exists() {
if [[ $# -ne 1 ]]; then
prnt E "function_exists(): A function name is required!"
die 11 --force
fi
LC_ALL=C type -t $1 | grep function
return $?
}

View File

@@ -13,7 +13,7 @@
get_os_version()
{
if [[ ! -f /etc/os-release ]]; then
prnt E "Your distribution doesn't have the needed os-release file."
prnt E "get_os_version(): Your distribution doesn't have the needed os-release file."
die 8 --force
fi
@@ -26,7 +26,7 @@ get_os_version()
source /etc/os-release
if [[ -z $ID ]]; then
prnt E "Your /etc/os-release file mises some vital information."
prnt E "get_os_version(): Your /etc/os-release file mises some vital information."
die --force 8
fi
@@ -50,7 +50,7 @@ export read_os_release
set_sys_vars()
{
if [[ $# -ne 4 ]]; then
prnt E "get_os_version(): incorect number of parameters ($@)."
prnt E "set_sys_vars(): Incorrect number of parameters ($@)."
die --force 7
fi

View File

@@ -16,7 +16,7 @@ read_commandline()
{
syntax_error()
{
prnt E "Error while analysing command line, please check your parameters."
prnt E "Error while analysing command line parameters."
die 1 --force
}
@@ -52,9 +52,9 @@ read_commandline()
if [[ -s $STAGE_FILE ]]; then
export RESUME=true
else
prnt E "The state file doesn't exists or is empty!"
prnt E "The status file doesn't exists or is empty!"
prnt E "Without it, resuming is impossible."
die 1 --force
die 17 --force
fi
;;
"-R"|"--no-root-check")
@@ -102,7 +102,7 @@ read_commandline()
export NEW_LOGFILE=$opt
want_logfile=false
else
prnt E "It's impossible to specify several log files."
prnt E "Impossible to specify several log files."
die 1 --force
fi
elif [[ $want_conffile == true ]]; then