[Top][All Lists]

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

Re: Operator || disables set -e in subshells: Bug or feature?

From: Eric Blake
Subject: Re: Operator || disables set -e in subshells: Bug or feature?
Date: Mon, 19 May 2008 19:16:03 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20080421 Thunderbird/ Mnenhy/

Hash: SHA1

According to address@hidden on 5/19/2008 7:16 AM:
| Bash Version: 3.1
| Patch Level: 17

Consider upgrading.  Bash is at 3.2, patch level 39.  However, it also
exhibits the same behavior.

|       Today I recognized a strange behavior of Bash with set -e and operator
|| (same for && as well).

POSIX states:
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.


As worded, this is slightly ambiguous - you can argue, as ash does, that
all simple commands in the subshell are subject to the most recent 'set
- -e' also in that subshell; or you can argue, as bash, ksh, and zsh do,
that the entire subshell is part of an exempt compound list, therefore the
setting or clearing of 'set -e' in the subshell is irrelevant since the
entire subshell is exempt.

If you need more clarification, I would ask on the Austin Group mailing
list if this ambiguity was intended.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

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