Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Regression with stdin handling in non-interactive mode between 5.8 and 5.8.1
> On 03 March 2022 at 09:39 Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote> > On 02 March 2022 at 22:38 Lyude Paul <lyude@xxxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author