[2018-11-20 10:15] Jonathan de Boyne Pollard <j.deboynepollard-newsgro...@ntlworld.com> > > part text/plain 1073 > 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.)
I believe I already wrote in init-d-script(5) correct invocation: #!/usr/bin/env /lib/init/init-d-script > 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 True, many do it this way. > 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: I do not object `exit $?'. But last line of `init-d-script' is `exit 0'. But thank you for your explanation. Now I agrue to change `exit 0' to `exit $?'.