Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Loops and pipes



Tangentially related, since this refactoring also loses the subshell's exit code and is still no help with `break`:

    read -E < <(echo $x; false)

Bash introduced a feature in 4.4 whereby process substitution places the child process's PID into $! so that its exit code can then be checked with `wait`. Any interest in doing likewise in Zsh?

On Fri, Jul 31, 2026 at 5:53 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
This should have been obvious in retrospect, but it just bit me:

continue and break on the left side of a pipe are useless.

Stupid example:

for x in 1 2 3; do
{ echo $x; false || break } | read -E
done
1
2
3

Would anyone have an issue with break / continue causing an error if
either appears in a subshell where the surrounding loop is in the
parent?  (I have not yet investigated implementation.)

Tangentially:

% continue
continue: not in while, until, select, or repeat loop

Shouldn't that also mention "for" loops?



--
Mark J. Reed <markjreed@xxxxxxxxx>


Messages sorted by: Reverse Date, Date, Thread, Author