From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Lyude Paul <lyude@redhat.com>, zsh-workers@zsh.org
Subject: Re: Regression with stdin handling in non-interactive mode between 5.8 and 5.8.1
Date: Thu, 3 Mar 2022 11:52:39 +0000 (GMT) [thread overview]
Message-ID: <1630957415.1168113.1646308359498@mail2.virginmedia.com> (raw)
In-Reply-To: <142189641.1163040.1646300345691@mail2.virginmedia.com>
> On 03 March 2022 at 09:39 Peter Stephenson <p.w.stephenson@ntlworld.com> wrote> > On 02 March 2022 at 22:38 Lyude Paul <lyude@redhat.com> wrote:
> > Running on zsh 5.8 returns:
> >
> > Shell is 70
> > Shell is 71
> >
> > Running on zsh 5.8.1 however, returns:
> >
> > Shell is 86396
> > Shell is 86396
>
> Thanks for the nice simple test --- I'll try and concoct something similar
> but predictable for the shell tests.
Added to the patch; I've confirmed this succeeds or fails as expected.
pws
diff --git a/Src/input.c b/Src/input.c
index caeaff0e3..50cd2cd78 100644
--- a/Src/input.c
+++ b/Src/input.c
@@ -223,13 +223,20 @@ shingetchar(void)
return STOUC(*shinbufptr++);
shinbufreset();
- do {
+ for (;;) {
errno = 0;
- nread = read(SHIN, shinbuffer, SHINBUFSIZE);
- } while (nread < 0 && errno == EINTR);
- if (nread <= 0)
+ nread = read(SHIN, shinbufendptr, 1);
+ if (nread > 0) {
+ /* Use line buffering (POSIX requirement) */
+ if (*shinbufendptr++ == '\n')
+ break;
+ if (shinbufendptr == shinbuffer + SHINBUFSIZE)
+ break;
+ } else if (nread == 0 || errno != EINTR)
+ break;
+ }
+ if (shinbufendptr == shinbuffer)
return -1;
- shinbufendptr = shinbuffer + nread;
return STOUC(*shinbufptr++);
}
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 4e39a8f3c..0312fe94e 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -961,3 +961,12 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci
F:This test was written to ensure the behaviour doesn't change silently.
F:If this test fails during development, it *might* be appropriate to change
F:its expectations.
+
+ (
+ export VALUE=first
+ print -l 'echo Value is $VALUE' 'VALUE=second sh' 'echo Value is $VALUE' |
+ $ZTST_testdir/../Src/zsh -f
+ )
+0:Non-interactive shell command input is line buffered
+>Value is first
+>Value is second
next prev parent reply other threads:[~2022-03-03 11:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-02 22:38 Lyude Paul
2022-03-02 22:59 ` Bart Schaefer
2022-03-03 9:39 ` Peter Stephenson
2022-03-03 11:52 ` Peter Stephenson [this message]
2022-03-03 22:59 ` Lyude Paul
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=1630957415.1168113.1646308359498@mail2.virginmedia.com \
--to=p.w.stephenson@ntlworld.com \
--cc=lyude@redhat.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).