regression in reading variables from pipe for external processes (Issue #8)
Quoted 21 lines · arĉi
this script
```shell printf '1\n2\n' | while read i; do /bin/echo "$i" done ``` outputs ``` 1 ``` while this script ```shell printf '1\n2\n' | while read i; do echo "$i" done ``` outputs ``` 1 2 ```
Quoted 3 lines
(as expected)
both scripts emit second output on release.
git-bisect revealed this was introduced in44b15ea09a9ee5872cf477e4ffc6b42ef37d1e46
Thanks for the report.
This means that fallback code-path when tee(2) isn't available isn't working. Perhaps the seek testing isn't working as expected.
Unfortunately I couldn't reproduce this on Linux. Please tell us what OS you're using and provide a strace of the failing execution.
There was another similar report about this:
https://lore.kernel.org/dash/[email protected]/T/#t
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 1/1 eval: Reset input for pipelines
In reply to a message not in the archiveQuoted 3 lines · arĉi
I'm on Arch Linux.
<details><summary>strace</summary>
Oops, this has nothing to do with the other bug report. Indeed I could reproduce this. The issue is a missing reset_input call for pipelines.
Thanks,
---8<---
For everything but the first component of a pipeline, the input needs to be reset because it is no longer equal to that of the parent shell.
--- src/eval.c | 1 + 1 file changed, 1 insertion(+)
src/eval.c +1 -0
@@ -595,6 +595,7 @@ evalpipe(union node *n, int flags)close (pip[0 ]); }if (prevfd >0 ) { +reset_input ();dup2 (prevfd,0 );close (prevfd); }
Signature · 6 lines
2.39.2 -- Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt