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

TRAPZERR and interrupting loops



I've had trouble for some time now with interrupting loops when
TRAPZERR is defined.  I've finally taken the time to figure out what's
going on in the code to cause this.

It appears that when doshfunc() is called inside dotrap(), the variable
"breaks" is being reset and causing the loop to not end as it does
without TRAPZERR being set.  I put code in to save the old value and
restore it after the call to doshfunc(), and it seems to work okay.  I
have no idea what else it breaks, though.  It would be good if someone
more familiar with this code could take a look.

To reproduce:

prompt% ./zsh -f
prompt% for x in 1 2 3 4 5; do
> echo $x
> sleep 1
> done

(hit ^C here and the loop will end)

prompt% TRAPZERR() { echo darn }

(run the same loop again, hit return, and the loop will not end)

Also, I noticed that lastval is defined as a long in globals.h, but it
is assigned to an int in signals.c/dotrap() (savval) and exec.c/doshfunc()
(oldlastval).  I'm not sure if lastval should be an int or the others
should be longs.

All this is with 2.6-beta11 on SunOS 4.1.3.

Thanks,
Mark



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