Configuration Information [Automatically generated, do not change]: Machine: i386 OS: linux-gnu Compiler: i386-redhat-linux-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 uname output: Linux hummer.3amok 2.6.12-1.1381_FC3smp #1 SMP Fri Oct 21 04:03:26 EDT 2005 i686 i686 i386 GNU/Linux Machine Type: i386-redhat-linux-gnu
Bash Version: 3.0 Patch Level: 14 Release Status: release Description: The attached script (below) sets the 'exit-on-error' option, in order to prevent deletion of an item if the archiving command fails. However, Bash fails to stop the script when an error occurs, and the item is deleted anyway, which is very unfortunate :( The Bash Reference Manual vaguely refers to '&&' when defining the '-e' option: "Exit immediately if a simple command exits with a non-zero status, unless the command that fails is part of an until or while loop, part of an if statement, part of a && or || list..." *Vaguely*, because it does not specify what is means to the "part of a && list." The && list is defined as: "command1 && command2: command2 is executed if, and only if, command1 returns an exit status of zero." Unfortunately, when "&& list" and "set -e" are used together as in the attached script, they effectively cancel each other out, and result in a non-robust script, which doesn't handle errors. The claim: My claim is that in the attached script, the 'false' command should *not* be considered to be a part of the && list. It is a part of function 'archive_item', which is a part of the script. The behavior of 'archive_item' should not change depending on the context, in which it is invoked from. Script: #! /bin/bash set -e archive_item() { set -e false # this is the command that fails to archive the item echo 'Archived.' } delete_item() { true # this is the command that deletes the item echo 'Deleted!' } archive_item && delete_item Expected output: <empty> Actual output: Archived. Deleted! _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash