zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <schizo@debian.org>
To: Vincent Lefevre <vincent@vinc17.org>,
	514857@bugs.debian.org, 519571@bugs.debian.org,
	520101@bugs.debian.org
Cc: zsh-workers@sunsite.dk
Subject: Re: Bug#514857: zsh -c 'set -e; ! true; echo OK' fails
Date: Wed, 25 Mar 2009 14:57:35 +0000	[thread overview]
Message-ID: <20090325145735.GC9330@scru.org> (raw)
In-Reply-To: <20090317114619.GA12579@vin.lip.ens-lyon.fr> <20090313145134.GA23870@vin.lip.ens-lyon.fr> <20090211123454.GA20425@vin.lip.ens-lyon.fr>

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).


       reply	other threads:[~2009-03-25 14:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090317114619.GA12579@vin.lip.ens-lyon.fr>
     [not found] ` <20090313145134.GA23870@vin.lip.ens-lyon.fr>
     [not found]   ` <20090211123454.GA20425@vin.lip.ens-lyon.fr>
2009-03-25 14:57     ` Clint Adams [this message]
2009-03-25 16:31       ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090325145735.GC9330@scru.org \
    --to=schizo@debian.org \
    --cc=514857@bugs.debian.org \
    --cc=519571@bugs.debian.org \
    --cc=520101@bugs.debian.org \
    --cc=vincent@vinc17.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).