Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: $(<nofile) doesn't set $? to non-zero
- X-seq: zsh-workers 42469
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: $(<nofile) doesn't set $? to non-zero
- Date: Fri, 16 Mar 2018 08:24:08 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sn8BIMcq7pBbX77nnNnmEMxHySOVSXVwHmoBtUPBE/k=; b=ccUbHmJ0g3EOuLdVXOQ7/3LGdRElfgzFiN+IE7tMdMF+6u6hO91xEZqQ01hP0GQtve FyQD1EeE0ldJYPAhA2tgY4Zu+vCFinzt/4/Ux/z1TVMQK2QfJ92weK3GdzUi3UMXYfoU 2w45CvmLGn8G9P2vPwIBALwDxGZ4ejBg7rVFZtWy3AVF63xNDVNyRxb7CDZ9L2KwL3oH 6gPgGKubyagxE9fKpT+cHasccjK8D5p7z9jsHLTu5d7IIPAn6elJsrZ4TQLbJOF+tHJy mXko7lwJ4iRUWtzwkDkLrU0M2jGu1Yy4s7hAAthIQtFjfRBccINLyXAzL9suf+kSGn2Z tFKw==
- In-reply-to: <20180315111014.GA15289@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>
- 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> <20180314144248.GC10404@chaz.gmail.com> <20180314145004.6e4b971b@camnpupstephen> <20180315071204.GA10057@chaz.gmail.com> <20180315092305.6fe4ad17@camnpupstephen> <20180315111014.GA15289@chaz.gmail.com>
2018-03-15 11:10:14 +0000, Stephane Chazelas:
> 2018-03-15 09:23:05 +0000, Peter Stephenson:
> [...]
> > That should be more consistent, thanks. I've committed it (minor
> > tweaks).
> [...]
>
> Sorry, my bad, I've left an unused variable in the patch.
[...]
And worse, didn't even test the obvious $(<existing-file).
I promiss I'll do a "make test" in the future before submitting
any patch! Sorry again.
diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c
index 771e5b5..7a90341 100644
--- a/Src/Modules/mapfile.c
+++ b/Src/Modules/mapfile.c
@@ -197,9 +197,8 @@ get_contents(char *fname)
val = NULL;
if ((fd = open(fname, O_RDONLY | O_NOCTTY)) >= 0) {
LinkList ll;
- int readerror;
- if ((ll = readoutput(fd, 1, &readerror)))
+ if ((ll = readoutput(fd, 1, 0)))
val = peekfirst(ll);
}
#endif /* USE_MMAP */
diff --git a/Src/exec.c b/Src/exec.c
index ce8cf8c..35b0bb1 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4599,8 +4599,8 @@ readoutput(int in, int qt, int *readerror)
}
*ptr++ = c;
}
- if (readerror && ferror(fin))
- *readerror = errno;
+ if (readerror)
+ *readerror = ferror(fin) ? errno : 0;
fclose(fin);
while (cnt && ptr[-1] == '\n')
ptr--, cnt--;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author