You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] A command in a while read loop body takes the loop's stdin, so the loop stops after one pass #249
printf'a\nb\nc\n'> /tmp/list
whileread f;do ls / >/dev/null;echo"l:$f";done< /tmp/list
Same result with echo "$f" | cat, sh script.sh "$f" (a script that does not read stdin), and with the input piped in (printf … | while read f; do …; done).
Expected Behavior
bash runs every iteration:
l:a
l:b
l:c
Actual Behavior
l:a
strands-shell: read: bad fd 0
The loop runs once, then read has no stdin. Bodies made only of single builtins or function calls work (e(){ echo "f:$1"; }; while read f; do e "$f"; done < /tmp/list runs all three).
Additional Context
while read f; do <cmd> "$f"; done < list is a very common agent idiom, and it fails here without an error from the body itself.
Possible Solution
The likely cause is src/exec.rs:3483 in run_pipeline: shell_proc.transfer_fd(STDIN, &mut procs[0])moves the enclosing compound's stdin into stage 0, and the stage drops it when it finishes, whether or not it read anything. Giving stage 0 a shared handle (or handing the fd back after the pipeline) would keep unread input for the next loop iteration, like a real inherited fd.
Related Issues
#207, #224 (scripts now read their stage's stdin; the same fd lifetime applies)
Activity