Hi,

Is the following behavior intended?

I was surprised by the behavior of bash/zsh/ash/dash/pdksh,
yet Solaris 5.9's /bin/sh does what I expected:

  # Solaris 5.9's /bin/sh
  $ echo a; (set -e; false; echo foo) && echo b
  a

  # Yet bash/zsh/ash do this:
  $ echo a; (set -e; false; echo foo) && echo b
  a
  foo
  b

The POSIX spec for set's -e option says the following,
so it all comes down to how you interpret being ``part of
an AND or OR list'':

  -e When this option is on, if a simple command fails for any of the
  reasons listed in Section 2.8.1 (on page 46) 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.

My take was to consider the subshell commands in isolation,
where I expected the `set -e' to take effect.  There, the simple
command `false' fails, so I expected that subshell to exit nonzero
and not print `foo'.

I'm using:
  $ bash --version
  GNU bash, version 3.00.16(1)-release (i386-pc-linux-gnu)


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

Reply via email to