Dmitry Bogatov:

Can you please elaborate, what exactly would break?


Look at the way that the init-d-script script is used. It isn't used as the interpreter of an rc script. (Your manual needs fixing to show the correct way to invoke it, by the way.) It is invoked as:

#!/bin/sh
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi


init-d-script proceeds to source the script that sourced it. Consider what happens if its final action is not to exit $? . The shell returns to the original rc script, and runs the rest of it *again*. This wouldn't be a problem if rc scripts were purely pseudo-declarative, as it would just run some variable assignments and function definitions a second time. But in reality people are writing rc scripts like these, cargo-cult style:

* https://raw.githubusercontent.com/Sean-Der/fail2rest/master/init-scripts/debian.sh

* https://askubuntu.com/questions/1053107/

* https://forum.ubuntu.ru/index.php?topic=281688.msg2217941#msg2217941

Reply via email to