improved code quality, few bug fixes

This commit is contained in:
Geoffray Levasseur
2023-08-02 11:36:01 +02:00
parent e16ce485f9
commit cd35f52509
29 changed files with 174 additions and 168 deletions

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Various utilitary functions
# This file is part of the init.sh project
@@ -25,7 +26,7 @@ function_exists() {
die 11 --force
fi
if [[ $(LC_ALL=C type -t $1 | grep function) ]]; then
if [[ -n $(LC_ALL=C type -t $1 | grep function) ]]; then
return 0
else
return 1
@@ -42,7 +43,7 @@ get_mod_name()
prnt E "get_mod_name(): Bad number of parameters."
die 11 --force
fi
echo $(basename $1 | cut -f 1 -d '.')
basename $1 | cut -f 1 -d '.'
}
export -f get_mod_name
@@ -52,7 +53,7 @@ export -f get_mod_name
trim()
{
local string="$@"
echo "$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}")"
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'<<<"${string}"
unset string
}
export -f trim