[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#562506: init scripts should not use set -e



martin f krafft <madduck@debian.org> writes:

> I still think set -e is a good idea, but I realise it boils down to
> preference. If your experience is representative, then it's probably
> better to advocate not setting set -e in init scripts.

> What about maintainer scripts?

It's almost always correct, in a maintainer script, for the script to
abort if anything it attempted to do failed.  If the maintainer hadn't
anticipated that failure, having the script continue anyway risks in some
cases severe data corruption.  I think it's therefore much safer to have
set -e in maintainer scripts and support using it there.

With init scripts, however, since Debian Policy requires that starting a
daemon that's already running or stopping a daemon that isn't running
succeed, set -e requires special checking for those cases.  If the
maintainer does that when writing the init script, great, but it seems to
be a very frequent source of bugs.  (I just ran into another case of that
the other day and need to file a bug about it.)

Init scripts also produce output normally, but if echo fails because
something is wrong with the console, having the init script silently abort
is very tricky to debug.  I suppose that's also the same with maintainer
scripts, but it's much less common for maintainer scripts to echo things
to the console.

-- 
Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>



Reply to: