Hello.
In /etc/bash.bashrc.local, I set some system global env variables. I also defines some global definition functions that does not exists by default in bash. All these definitions aim to be available to all users in any bash script.
To prevent multiple source action, a readonly variable is used
if test -z "$SOURCED_SYS_COMMON_FUNC" ; then
test -s /backup_sys/VAR/MY_ENV_VAR/zzzz2_system_common_func.sh && . /backup_sys/VAR/MY_ENV_VAR/zzzz2_system_common_func.sh
if [[ -z "$(LC_ALL=C type stop_or_continue 2>/dev/null)" ]] ; then
MY_LOGGER2 "FATAL ERROR --- stop_or_continue function not defined --- COMMON FUNCTIONS NOT SOURCED : zzzz2_system_common_func.sh" "0"
else
readonly SOURCED_SYS_COMMON_FUNC=true
export SOURCED_SYS_COMMON_FUNC
fi
else
MY_LOGGER2 "COMMON FUNCTIONS ALREADY SOURCED : zzzz2_system_common_func.sh" "5"
fi
When opening a kde konsole from application launcher, the function definitions are lost without any error message ( but the variables definitions are still present ).