Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug#514857: zsh -c 'set -e; ! true; echo OK' fails
- X-seq: zsh-workers 26786
- From: Clint Adams <schizo@xxxxxxxxxx>
- To: Vincent Lefevre <vincent@xxxxxxxxxx>, 514857@xxxxxxxxxxxxxxx, 519571@xxxxxxxxxxxxxxx, 520101@xxxxxxxxxxxxxxx
- Subject: Re: Bug#514857: zsh -c 'set -e; ! true; echo OK' fails
- Date: Wed, 25 Mar 2009 14:57:35 +0000
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <20090317114619.GA12579@xxxxxxxxxxxxxxxxxxx> <20090313145134.GA23870@xxxxxxxxxxxxxxxxxxx> <20090211123454.GA20425@xxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Vincent Lefevre <vincent@xxxxxxxxxx>, 514857@xxxxxxxxxxxxxxx, 519571@xxxxxxxxxxxxxxx, 520101@xxxxxxxxxxxxxxx, zsh-workers@xxxxxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20090317114619.GA12579@xxxxxxxxxxxxxxxxxxx> <20090313145134.GA23870@xxxxxxxxxxxxxxxxxxx> <20090211123454.GA20425@xxxxxxxxxxxxxxxxxxx>
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).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author