zsh-users
 help / color / mirror / code / Atom feed
* signals in loops
@ 2002-10-22  2:49 bperkins
  2002-10-22 15:50 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: bperkins @ 2002-10-22  2:49 UTC (permalink / raw)
  To: zsh-users

I've been using zsh for a while, and I'd swear you used to be able to
do this:

for foo in 1 2 3 4 5 6 ; do xmessage $foo; done


and you could give control-c to kill the xmessage and the next one
would pop up.  In fact in a bash FAQ I found (which has this same
behavior, BTW), it said that if you wanted this to happen (with control-z
anyway), you have to type:

(for foo in 1 2 3 4 5 6 ; do xmessage $foo; done)

Which make complete sense to me, since the for loop can't receive a
signal unless it's a subshell.

It seems that this essentially does things the old way:

( trap continue INT; for foo in 1 2 3 4 5 ; do xmessage $foo ; done)

Which brings up a mostly acidemic question, what is the default
"trap?"

It seems to be something like:

trap "break -1" INT

Assuming that break -1 breaks from all loops.

--
"I know you believe you understand what you think I said, but I am not
            sure you realise that what you heard is not what I meant."
			    -- Alan Greenspan
Brian Perkins                                bperkins@netspace.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: signals in loops
  2002-10-22  2:49 signals in loops bperkins
@ 2002-10-22 15:50 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2002-10-22 15:50 UTC (permalink / raw)
  To: bperkins, zsh-users

On Oct 21, 10:49pm, bperkins@netspace.org wrote:
} Subject: signals in loops
}
} I've been using zsh for a while, and I'd swear you used to be able to
} do this:
} 
} for foo in 1 2 3 4 5 6 ; do xmessage $foo; done
} 
} and you could give control-c to kill the xmessage and the next one
} would pop up.

Yes, you did used to be able to do that.  It was a bug. :-)  To see why
it was a bug, consider trying to interrupt this:

	while : ; do something; done

} Which brings up a mostly acidemic question, what is the default
} "trap?"

There isn't any way to write the default signal handling behavior in the
shell language.  Effectively you're correct that it breaks from all loops
on the INT or QUIT signals.

On the TSTP signal, recent versions of zsh implicitly force the entire
loop into a subshell in order to be able to stop it.  Forking that sub-
shell is delayed until the signal is actually received.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-22 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-22  2:49 signals in loops bperkins
2002-10-22 15:50 ` 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).