On 01/24/2012 02:53 AM, Jim Avera wrote: > Description: > set -e in (subshells) should be independent of surrounding context. > The man page says "[set -e] applies to the shell environment and > each subshell environment separately", > but actually set -e is prevented from working in a (subshell) if it is > disabled in the > surrounding context. > > Repeat-By: > set +e > ( > set -e > cat /non/existent/path > echo "Did not abort. Isn't this a bug?" > ) || true
Alas, POSIX requires this behavior. http://austingroupbugs.net/view.php?id=52 > In summary, shouldn't set -e in (subshell code) operate independently > of the surrounding context? No. The POSIX description is clear that surrounding context affects whether set -e is ignored in a subshell. 2) The -e setting shall be ignored when executing the compound list following the while, until, if, or elif reserved word, a pipeline beginning with the ! reserved word, or any command of an AND-OR list other than the last. My personal advice - don't ever expect 'set -e' to work; there are just too many pitfalls and buggy shell implementations with differing interpretations to ever expect it to be useful, even if there is a standardized documentation for how it should behave, and even if bash has (finally) caught up to the standards. -- Eric Blake ebl...@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature