bug-bash
[Top][All Lists]
Advanced

[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:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to bug-bash-reply@03.softkill.org 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.

http://www.opengroup.org/onlinepubs/009695399/utilities/set.html

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             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
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

iEYEARECAAYFAkgyJlMACgkQ84KuGfSFAYALcACg19ByNDCtc8KO6hVaMIIT0fPL
1JsAnRWwG5PJJtqbI46cH67JXlzBuFCS
=Neop
-----END PGP SIGNATURE-----




reply via email to

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