Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $(<nofile) doesn't set $? to non-zero
- X-seq: zsh-workers 42461
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: $(<nofile) doesn't set $? to non-zero
- Date: Wed, 14 Mar 2018 10:54:42 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180314105445euoutp02a04397a7793f3e808a58606f95508515~bxBMqhHAF2580225802euoutp02j
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521024885; bh=wrK0D8qWmI7ilJFDT/UleTEKC6mnumvhqKDRRAco+yY=; h=Date:From:To:Subject:In-reply-to:References:From; b=r0M4Sadsm1RlmEjsZ5+BmZMZiNcrxpfFgoMUtudV8IdK8B7thojauNJeB3whEcI5b ECOSMXF321Yj/zaWYwp7mkRQTA+cxEVxb12HgsRFDhCoWpskkCc+FgdlCjnHmIjLBF eK1ilNuB/EByr92gWrk6cVW2Y8583stLXeRQqsjY=
- In-reply-to: <20180314103254.GA10404@chaz.gmail.com>
- 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>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180314103335epcas4p30222f0df02adda27cbddbe62075ff9ad@epcas4p3.samsung.com> <20180314103254.GA10404@chaz.gmail.com>
On Wed, 14 Mar 2018 10:32:54 +0000
Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> $ zsh -c 'ar=$(<file); echo "$?"'
> zsh:1: no such file or directory: file
> 0
>
> That's different from other shells (ksh93, bash, mksh) that
> return 1, and is also inconsistent with the cases where $(<) is
> not recognised as that operator and runs the NULLCMD instead:
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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author