mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
49792: Non-interative shell input is line buffered.
This commit is contained in:
parent
2be2efc122
commit
1640457f47
3 changed files with 26 additions and 7 deletions
|
@ -1,5 +1,8 @@
|
|||
2022-03-03 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* 49792: Src/input.c, Test/A01grammar.ztst: Use line buffering
|
||||
for non-interactive input.
|
||||
|
||||
* 49787: Test/W02jobs.ztst, Test/W03jobparameters.ztst: test for
|
||||
jobs fix in 49783.
|
||||
|
||||
|
|
21
Src/input.c
21
Src/input.c
|
@ -223,13 +223,20 @@ shingetchar(void)
|
|||
return STOUC(*shinbufptr++);
|
||||
|
||||
shinbufreset();
|
||||
do {
|
||||
errno = 0;
|
||||
nread = read(SHIN, shinbuffer, SHINBUFSIZE);
|
||||
} while (nread < 0 && errno == EINTR);
|
||||
if (nread <= 0)
|
||||
return -1;
|
||||
shinbufendptr = shinbuffer + nread;
|
||||
for (;;) {
|
||||
errno = 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;
|
||||
return STOUC(*shinbufptr++);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue