* Bug: function calls with break in preexec
@ 2023-09-16 15:08 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2023-09-16 15:08 UTC (permalink / raw)
To: Zsh hackers list
This nofork test is what got me here:
repeat 3 do purr ${
for x in 1 2 3 4
do (( x == 3 )) && break 2; print $x
done
} XX
done
This fails when added to the test suite because it produces no output at all.
"purr" is a function:
purr() { print -r -- "$@" }
If "purr" is replaced by "print -r --" in the repeat loop, everything
works as expected, the output is
1
2 XX
Its important that the ${ ... } is expanded by preexec() before the
function is called. After scratching my head for a while I came up
with a way to have that happen even without the nofork patches:
repeat 3 print c*(oe:'break':)
prints all the files starting with "c" (e.g., run it in the zsh source
tree) but only once. Conversely,
repeat 3 purr c*(oe:'break':)
prints nothing. "set -x" shows the function call being made, but it
immediately stops without executing any commands.
One of these cases has to be wrong: Either the loop should break
immediately, so neither the builtin nor the function runs, or the
function should run and then the loop should break. Or more
radically, a break occurring in the argument expansions should just be
discarded, but that seems wrong too. I think it's the former: The
builtin shouldn't run in this case.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-16 15:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-16 15:08 Bug: function calls with break in preexec Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).