> I'm noticing a difference in behavior between Solaris 9's sh and GNU
> bash, and was wondering if this is a bug or a feature.

It's a POSIX requirement.

> Using GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu).
> This command:
> 
>     bash -exc 'for x in a b c; do ( false ); echo status is $?; done'
> 
> loops through three items (a b c) and executes a failing command in a
> subshell.  I was expecting the outer shell to notice that the exit
> status from the subshell is nonzero and terminate immediately; instead
> it prints "status is 1" and continues looping.

According to POSIX, `set -e' only affects the execution of simple commands.
A command in a subshell is not a simple command.

You can look at the grammar at
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_10

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                                Live Strong.
Chet Ramey, ITS, CWRU    [EMAIL PROTECTED]    http://tiswww.tis.case.edu/~chet/


_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to