From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: $(<nofile) doesn't set $? to non-zero
Date: Fri, 16 Mar 2018 08:24:08 +0000 [thread overview]
Message-ID: <20180316082408.GA23397@chaz.gmail.com> (raw)
In-Reply-To: <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--;
next prev parent reply other threads:[~2018-03-16 8:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180314103335epcas4p30222f0df02adda27cbddbe62075ff9ad@epcas4p3.samsung.com>
2018-03-14 10:32 ` Stephane Chazelas
2018-03-14 10:54 ` Peter Stephenson
2018-03-14 14:42 ` Stephane Chazelas
2018-03-14 14:50 ` Peter Stephenson
2018-03-15 7:12 ` Stephane Chazelas
2018-03-15 7:25 ` EILSEQ in the C locale? (Was: $(<nofile) doesn't set $? to non-zero) Stephane Chazelas
2018-03-19 0:09 ` Bart Schaefer
2018-03-15 9:23 ` $(<nofile) doesn't set $? to non-zero Peter Stephenson
2018-03-15 11:10 ` Stephane Chazelas
2018-03-16 8:24 ` Stephane Chazelas [this message]
2018-03-14 11:04 ` Stephane Chazelas
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=20180316082408.GA23397@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/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).