A trio regarding set -e: On Wed, Feb 11, 2009 at 01:34:54PM +0100, Vincent Lefevre wrote: > The command > > zsh -c 'set -e; ! true; echo OK' > > fails to output OK, thus does not conform to POSIX: > > -e When this option is on, if a simple command fails for any of the > reasons listed in Section 2.8.1 (on page 2315) 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. > > bash, dash and ksh93 are correct (but not pdksh, posh and zsh). > > There's currently a discussion about "set -e" in the austin group > mailing-list, but there does not seem to be any ambiguity on the > above point, as only "! true" returns an exit status value >0 but > this is not a simple command. And concerning historical behavior, > both ksh93 and bash output OK. So, I think that pdksh, posh and > zsh should follow.
On Fri, Mar 13, 2009 at 03:51:34PM +0100, Vincent Lefevre wrote: > According to the new "set -e" proposal > > http://www.opengroup.org/austin/mailarchives/ag/msg18258.html > > zsh -c 'set -e; ! if true; then false; fi; echo $?' > > should output 0, i.e. "false" should not make the shell exit, because > it is under a "!" context (even though "!" doesn't apply on the "false" > command directly). > > Note that every other shell (bash, ksh93, pdksh, dash, posh) output 0. On Tue, Mar 17, 2009 at 12:46:20PM +0100, Vincent Lefevre wrote: > POSIX shells (bash, dash, ksh93, pdksh, posh) return with no output > and an exit status equal to 1 on: > > sh -c 'set -e; foo() { false && false; }; foo; echo $?' > > but zsh doesn't, even with "emulate sh": > > $ zsh -fc 'emulate sh; set -e; foo() { false && false; }; foo; echo $?' > 1 > > zsh should match the existing practice (perhaps even without > "emulate sh", unless this can break too many zsh scripts). -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org