[Resolvconf-devel] Bug#518359: resolvconf: bug in shell script leads to early exit - resolv.conf is not filled with nameserver entries - with fix
Adam D. Barratt
adam at adam-barratt.org.uk
Thu Mar 5 19:27:37 UTC 2009
On Thu, 2009-03-05 at 17:18 +0000, Thorsten Glaser wrote:
> the /etc/resolvconf/update.d/libc script contains "set -e", which
> means the shell aborts execution if one of the commands returns
> a non-zero exit status.
Correct, however...
> The aforementioned script contains instructions ("[ ... ]") that
> do so and thusly fails to work. These familiar with Makefiles,
> which exhibit similar behaviour, know to use negative logic, i.e.
> [ x != y ] || foo instead of [ x = y ] && foo, instead.
... the use of && avoids that.
The description of "set -e" in SUSv3 reads:
-e
When this option is on, if a simple command fails for any of the
reasons listed in Consequences of Shell Errors or returns an exit
status value >0, and is not part of the compound list following a
while, until, or if keyword, and is not a part of an AND or OR list,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and is not a pipeline preceded by the ! reserved word, then the
shell shall immediately exit.
It's also trivial to produce an example demonstrating that this is the case:
$ cat foo
#! /bin/sh
set -e
[ "A" = "B" ] && echo Hello
echo Goodbye
$ ./foo
Goodbye
There may be some other reason why the script apparently doesn't work,
but the use of && and set -e isn't it.
Regards,
Adam
More information about the Resolvconf-devel
mailing list