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.

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.

+ for x in a b c
+ false
+ echo status is 1
status is 1
+ for x in a b c
+ false
+ echo status is 1
status is 1
+ for x in a b c
+ false
+ echo status is 1
status is 1

sh on Solaris does what I expected, namely just execute "false" once and
bail:

$ sh -exc 'for x in a b c; do ( false ); echo status is $?; done'
+ false

So... bug or feature?  Thanks in advance for the help.

- Jon



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

Reply via email to