Writing the scripts
@@ -6061,6 +6061,23 @@ rmdir /usr/local/share/emacs 2>/dev/null || true
option.
+
+ Be careful of using set -e in init.d
+ scripts. Writing correct init.d scripts requires
+ accepting various error exit statuses when daemons are already
+ running or already stopped without aborting
+ the init.d script, and common init.d
+ function libraries are not safe to call with set -e
+ in effect
+ /lib/lsb/init-functions, which assists in writing
+ LSB-compliant init scripts, may fail if set -e is
+ in effect and echoing status messages to the console fails,
+ for example.
+ . For init.d scripts, it's often easier
+ to not use set -e and instead check the result of
+ each command separately.
+
+
If a service reloads its configuration automatically (as
in the case of cron, for example), the
@@ -7158,13 +7175,19 @@ strip --strip-unneeded your-lib
language currently used to implement it.
- Shell scripts (sh and bash)
- should almost certainly start with set -e so that
- errors are detected. Every script should use
- set -e or check the exit status of every
- command.
+ Shell scripts (sh and bash) other than
+ init.d scripts should almost certainly start
+ with set -e so that errors are detected.
+ init.d scripts are something of a special case, due
+ to how frequently they need to call commands that are allowed to
+ fail, and it may instead be easier to check the exit status of
+ commands directly. See [ for more
+ information about writing init.d scripts.
+ ]
+
+ Every script should use set -e or check the exit status
+ of every command.
-
Scripts may assume that /bin/sh implements the
SUSv3 Shell Command Language