better self explain

This commit is contained in:
m8in
2026-04-25 20:50:23 +02:00
parent 1a9acbb9e5
commit 5ebba17d04
+23 -4
View File
@@ -203,8 +203,6 @@ function base.filterComments(){
return 1 return 1
} }
# Funktionen von Module, die mit dieser Funktion geladen werden, behalten ihren Name.
# Deshalb dürfen solche Funktionen auch nicht per '→ FunktionsName' aufgerufen werden!
function base.loadModule() { function base.loadModule() {
local _MODULENAME _MODULEFULLNAME local _MODULENAME _MODULEFULLNAME
_MODULENAME="${1:?"Function base.loadModule(): Missing parameter MODULENAME."}" _MODULENAME="${1:?"Function base.loadModule(): Missing parameter MODULENAME."}"
@@ -257,6 +255,23 @@ function base.log() {
esac esac
} }
function base.printEnvironment() {
# Check precondition
[[ "${CIS[SET]:+isset}" != "isset" ]] \
&& declare -A -g CIS=([SET]=unprepared) \
&& prepare.setCIS
[[ "${CIS[SET]:+isset}" != "isset" ]] \
&& return 1
echo "Content of array CIS:"
echo "---------------------"
for _KEY in "${!CIS[@]}"; do
printf " %s\n" "CIS[${_KEY}]: ${CIS[${_KEY}]}\n"
done
return 0
}
function base.printModuleFunctions() { function base.printModuleFunctions() {
local _MODULENAME local _MODULENAME
_MODULENAME="${1:?"Function base.printModuleFunctions(): Missing parameter MODULENAME."}" _MODULENAME="${1:?"Function base.printModuleFunctions(): Missing parameter MODULENAME."}"
@@ -323,14 +338,18 @@ if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
echo "FAILURE: you are using this module 'base.sh' in a wrong way." echo "FAILURE: you are using this module 'base.sh' in a wrong way."
echo " It is intended as a utility library and should not be called directly." echo " It is intended as a utility library and should not be called directly."
echo echo
echo "Usage: Call the base module at the beginning of your script e.g. like this:" echo "Usage: Call the base module at the beginning of your script, like this:"
echo "-----------------------------------------------------------------------"
echo echo
echo '#!/bin/bash' echo '#!/bin/bash'
echo 'source /cis/core/base.module.sh' echo 'source /cis/core/base.module.sh'
echo echo
echo
base.printEnvironment
echo
echo "Now you can use the functions provided by this module inside your script:" echo "Now you can use the functions provided by this module inside your script:"
echo "-------------------------------------------------------------------------" echo "-------------------------------------------------------------------------"
declare -F | grep "base." | cut -d" " -f3 declare -F | grep "base." | cut -d" " -f3 | xargs -n1 printf " %s\n"
exit 1 exit 1
else else
# If not exists, define a global array 'COLOR' # If not exists, define a global array 'COLOR'