source: return from source to avoid killing shell

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-01 09:37:22 +01:00
parent c1aec9285e
commit e86c8dc116

View File

@ -30,7 +30,7 @@ BOTCOMMANDS="-h help init start stop status suspendback resumeback killb
# 8 - curl/wget missing # 8 - curl/wget missing
# 10 - not bash! # 10 - not bash!
# #
#### $$VERSION$$ v1.40-dev-24-ge4a983b #### $$VERSION$$ v1.40-dev-25-gc1aec92
################################################################## ##################################################################
# emmbeded system may claim bash but it is not # emmbeded system may claim bash but it is not
@ -51,6 +51,7 @@ if [ -t 1 ] && [ -n "${TERM}" ]; then
NC='\e[0m' NC='\e[0m'
NN="${NC}\n" NN="${NC}\n"
fi fi
declare -r INTERACTIVE RED GREEN ORANGE GREY NC NN
# telegram uses utf-8 characters, check if we have an utf-8 charset # telegram uses utf-8 characters, check if we have an utf-8 charset
if [ "${LANG}" = "${LANG%[Uu][Tt][Ff]*}" ]; then if [ "${LANG}" = "${LANG%[Uu][Tt][Ff]*}" ]; then
@ -179,8 +180,9 @@ RUNDIR="$(dirname "$0")"
MODULEDIR="${SCRIPTDIR}/modules" MODULEDIR="${SCRIPTDIR}/modules"
# adjust locations based on source and real name # adjust stuff for source
[[ "${SCRIPT}" != "${REALME}" || "$1" == "source" ]] && SOURCE="yes" alias exit_source='exit'
[[ "${SCRIPT}" != "${REALME}" || "$1" == "source" ]] && SOURCE="yes" && alias exit_source='printf "Exit from source...\n";return'
if [ -n "${BASHBOT_HOME}" ]; then if [ -n "${BASHBOT_HOME}" ]; then
SCRIPTDIR="${BASHBOT_HOME}" SCRIPTDIR="${BASHBOT_HOME}"
@ -221,9 +223,11 @@ RUNDIR="."
# check if JSON.sh is available # check if JSON.sh is available
JSONSHFILE="${BASHBOT_JSONSH:-${SCRIPTDIR}/JSON.sh/JSON.sh}" JSONSHFILE="${BASHBOT_JSONSH:-${SCRIPTDIR}/JSON.sh/JSON.sh}"
[ ! -x "${JSONSHFILE}" ] &&\ if [ ! -x "${JSONSHFILE}" ]; then
printf "${RED}ERROR:${NC} ${JSONSHFILE} ${RED}does not exist, are we in dev environment?${NN}${GREY}%s${NN}\n"\ printf "${RED}ERROR:${NC} ${JSONSHFILE} ${RED}does not exist, are we in dev environment?${NN}${GREY}%s${NN}\n"\
"\$JSONSHFILE is set wrong or bashbot is not installed correctly, see doc/0_install.md" && exit 3 "\$JSONSHFILE is set wrong or bashbot is not installed correctly, see doc/0_install.md"
exit_source 3
fi
# file locations based on ENVIRONMENT # file locations based on ENVIRONMENT
BOTCONFIG="${BASHBOT_ETC:-.}/botconfig" BOTCONFIG="${BASHBOT_ETC:-.}/botconfig"
@ -376,7 +380,7 @@ sed '1ia' </dev/null 2>/dev/null || printf "${ORANGE}Warning: You may run on a B
#jsonDB is now mandatory #jsonDB is now mandatory
if ! _is_function jssh_newDB; then if ! _is_function jssh_newDB; then
printf "${RED}ERROR: Mandatory module jsonDB is missing or not readable!${NN}" printf "${RED}ERROR: Mandatory module jsonDB is missing or not readable!${NN}"
exit 6 exit_source 6
fi fi
# $1 URL, $2 filename in DATADIR # $1 URL, $2 filename in DATADIR
@ -529,7 +533,7 @@ else
else else
printf "${RED}Error: curl and wget not found, install curl!${NN}" printf "${RED}Error: curl and wget not found, install curl!${NN}"
fi fi
exit 8 exit_source 8
fi fi
fi fi
@ -701,7 +705,7 @@ bot_init() {
if ! _is_function send_message ; then if ! _is_function send_message ; then
printf "${RED}ERROR: send_message is not available, did you deactivate ${MODULEDIR}/sendMessage.sh?${NN}" printf "${RED}ERROR: send_message is not available, did you deactivate ${MODULEDIR}/sendMessage.sh?${NN}"
exit 1 exit_source 1
fi fi
# check if JSON.awk exist and has x flag # check if JSON.awk exist and has x flag