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

Re: How to misplace an entire pipeline



Here's a not-new bug (occurs in, e.g., 4.2.0) that I found while trying
to test the preceding patch for side-effects.

torch% sleep 200 | sleep 300 | while :; do read '?GO:' < /dev/tty; done
(rapid infinite loop printing "GO:" repeatedly)
^Z
zsh: suspended  sleep 200 | sleep 300 | 
zsh: running    while :; do; read '?GO:' < /dev/tty; done
torch% 

Note that it says the "while" loop is running, even though control has
returned to the top-level prompt.

If you bring this job back into the foreground, it now properly blocks
on the "read":

torch% fg
[1]  + continued  sleep 200 | sleep 300 | while :; do; read '?GO:' < /dev/tty;
done
GO:

Again, my patch didn't change this behavior, it's been this way for at
least several revisions.

It works somewhat better with "read -q".

In 4.2.0, at the prompt printed by read, ^Z is silently ignored.  Here is
what happens with ^C instead:

torch% sleep 200 | sleep 300 | while :; do read -q '?GO:' ; done  
GO:
torch% jobs
[1]    running    sleep 200 | sleep 300
torch% fg
fg: no current job
torch% %1
[1]  + running    sleep 200 | sleep 300

(These are now in the foreground.)

With my patch from 29677, 4.3.12-dev-1 still silently ignores the ^Z,
but now:

torch% sleep 200 | sleep 300 | while :; do read -q '?GO:' ; done  
GO:%
torch% 
[1]    interrupt  sleep 200 | sleep 300
torch% 

Which seems to make more sense.



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