bug-bash
[Top][All Lists]
Advanced

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

set -e is not clearly documented


From: Bartłomiej Palmowski
Subject: set -e is not clearly documented
Date: Mon, 7 Oct 2013 11:01:11 +0200

Hi,

lets consider the following:

$ echo $BASH_VERSION
4.1.2(1)-release
$ cat /etc/system-release
Red Hat Enterprise Linux Server release 6.3 (Santiago)
$ ( set -e; echo foo; false; echo bar; ) # this one is expected
foo
$ ( set -e; echo foo; false; echo bar; ) || true # this one is not expected
foo
bar

documentation (http://www.gnu.org/software/bash/manual/bash.html) states
that:

[...] The shell does not exit if the command that fails is part of the
command list immediately following a while or until keyword, part of the
test in an if statement, part of any command executed in a && or || [...]

In this case it is not clear since set -e is invoked inside subshell and ||
is outside this subshell.

What I would expect to happen is ( set -e; echo foo; false; echo bar; ) ||
exit $? to exit with exit code of a last failed command in a subshell.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]