Re: "bash -e" does not stop if subshell returns an error
From:
Paul Jarc
Subject:
Re: "bash -e" does not stop if subshell returns an error
Date:
Fri, 19 Mar 2004 12:04:53 -0500
User-agent:
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)
Andreas Luik <Andreas.Luik@orthogon.com> wrote:
> "bash -e" is supposed to stop execution if a command returns an exit
> status != 0. This does not work for subshells.
That's normal, and specified by POSIX. Only "simple commands" cause
the shell to exit when they fail, and subshells aren't simple
commands.
> This behaviour is also an incompatibility with standard Bourne/SysV
> Shells, e.g. the abovementioned command works on Sun Solaris with
> /bin/sh:
Yes, Solaris sh/ksh and FreeBSD sh exit. bash, FreeBSD ksh, and
NetBSD sh do not exit. This (along with other shell portability
gotchas) is documented at <URL:http://multivac.cwru.edu./lintsh/>.
paul