>> After upgrading to Debian 10 we noticed a slightly different behaviour >> in /lib/lsb/init-functions.d/40-systemd which caused one of our scripts >> to break and which also causes some /etc/init.d files like >> /etc/init.d/mysql >> to no longer to display their help text when calling them without a >> parameter. >> >> The root cause are accesses to the $1 and $2 variables without checking >> if they are defined beforehand. When running code using "set -u", this >> causes the above mentioned error. >>
Which command did you use to make that happen? I'm asking because I can't test it right now. >> I've outlined this very simple fix which bypasses all further tests if >> $1 and so on are undefined. >> >> $ diff -C 9 40-systemd.orig 40-systemd >> *** 40-systemd.orig 2019-05-24 22:58:59.000000000 +0200 >> --- 40-systemd 2019-07-09 16:40:39.642678140 +0200 >> *************** >> *** 1,18 **** >> --- 1,21 ---- >> # -*-Shell-script-*- >> # /lib/lsb/init-functions >> >> _use_systemctl=0 >> if [ -d /run/systemd/system ]; then >> >> if [ -n "${__init_d_script_name:-}" ]; then # scripts run >> with new init-d-script >> executable="$__init_d_script_name" >> argument="$1" >> + elif [ $# -eq 0 ] ; then >> + executable="$0" >> + argument="" >> elif [ "${0##*/}" = "init-d-script" ] || >> [ "${0##*/}" = "${1##*/}" ]; then # scripts run with >> old init-d-script >> executable="$1" >> argument="$2" >> else # plain old scripts >> executable="$0" >> argument="$1" >> fi > > Mert, since this basically your code, could you have a look at this. > It seems OK. What I'd rather do is drop the "##*/" substitution, and set a default value if $1 is unset, and let the statement continue: executable="$__init_d_script_name" argument="$1" elif [ "${0##*/}" = "init-d-script" ] || - [ "${0##*/}" = "${1##*/}" ]; then # scripts run with old init-d-script + [ "${0}" = "${1:-}" ]; then # scripts run with old init-d-script executable="$1" - argument="$2" + argument="${2:-}" else # plain old scripts executable="$0" argument="$1" Dropping the "##*/" substitution isn't actually related to this change but dropping it allows the use of ":-" syntax in the same line. I was in fact thinking about dropping it irrelevant to this issue. Another important issue here is the use of "set -e" and "set -u" on the /etc/init.d/mysql script. It is ineffective right now because later in 40-systemd file they are set back to their defaults (set +e and set +u). I don't know the policy or best practices about this topic but either one of the scripts should be accommodated to be in compliance with the other. I'm sorry I can't test any of this right now as I don't have a suitable and up-to-date test system ready and I'm not sure when I'll be. Regards