Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $(<nofile) doesn't set $? to non-zero
- X-seq: zsh-workers 42463
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: $(<nofile) doesn't set $? to non-zero
- Date: Wed, 14 Mar 2018 14:42:48 +0000
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=gSSlHtEpMeXEi4kdqf8jubAPPd0igDZpuvHYr+O9vUg=; b=rSCvhWUXnuE9HXG6SXZveUNt7BPDCph2OorTn1CoW4En3+iGfAQvlbe8kpHTe8lwmh tn518VVBLJQXhNJWmS4f3LAHMoh7h1LIleI54SnzaKmxRZYs6mVDXpD6S1r5Cw0/9FeQ WsfAmFIH3IYHaTohdr+yrgy5QvLlkl6O3O3WCvW06G/25rQinEcKrFJqipwMnKfhcbtl Cr+u6ZVd92q8MXRnR61cm/eViqek2qbJwTJtFRSq5ZalebrOSVTNk90sTT4xkZz2JEwh zFPgdyBCMVr5powaoWqNPgR7yCIOuRyJkuPBie+1IyfgWBsgI6QIJ7siEbfHJFt8i26o CzSA==
- In-reply-to: <20180314105442.28c5554a@camnpupstephen>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180314103335epcas4p30222f0df02adda27cbddbe62075ff9ad@epcas4p3.samsung.com> <20180314103254.GA10404@chaz.gmail.com> <20180314105442.28c5554a@camnpupstephen>
2018-03-14 10:54:42 +0000, Peter Stephenson:
[...]
> We set lastval = cmdoutval if it's an ordinary command substitution, so it's
> easy to make this consistent with that behaviour. Doing so seems
> unproblematic.
>
> pws
>
> diff --git a/Src/exec.c b/Src/exec.c
> index e5c6455..299b816 100644
> --- a/Src/exec.c
> +++ b/Src/exec.c
> @@ -4514,6 +4514,7 @@ getoutput(char *cmd, int qt)
> untokenize(s);
> if ((stream = open(unmeta(s), O_RDONLY | O_NOCTTY)) == -1) {
> zwarn("%e: %s", errno, s);
> + lastval = cmdoutval = 1;
> return newlinklist();
> }
> return readoutput(stream, qt);
Thanks. I think that code explains why we don't report an error
upon read errors ($(</), $(</dev/mem)) as we use the same
function that reads the output of normal command substitutions
where read errors are not expected (pipe).
I suppose it's the same in other shells.
Would it be worth doing some:
ret = readoutput(stream, qt);
if (errno) {
zwarn("%e: %s", errno, s);
lastval = cmdoutval = 1;
}
return ret;
there (or something cleaner to avoid relying on errno)?
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author