zsh-users
 help / color / mirror / code / Atom feed
* trap ERR
@ 2017-02-21  6:08 Ray Andrews
  2017-02-21 15:52 ` Ray Andrews
  0 siblings, 1 reply; 8+ messages in thread
From: Ray Andrews @ 2017-02-21  6:08 UTC (permalink / raw)
  To: Zsh Users

I haven't played around with traps much, but trying this in a script:

    trap 'echo ERROR at $0 $LINENO; return' ERR

    cp file1/tmp
    cp no_such_file/tmp
    cp file2/tmp

    # trap '' ERR

I want to return with the message at any error, and it does return, but 
it seems that the trap remains in effect which puzzles me since when a 
script quits, I expect things to be returned to stock, no?  The 
commented line kills the trap fine, but of course if I return at the 
first error, it's never executed.

Also, I'd expect to 'exit' a script, but it ends up killing the whole 
terminal.  I'm used to using 'return' but now that I stop to think about 
it, that should be wrong, no?




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

end of thread, other threads:[~2017-02-22  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21  6:08 trap ERR Ray Andrews
2017-02-21 15:52 ` Ray Andrews
2017-02-21 16:41   ` Peter Stephenson
2017-02-21 16:56     ` Ray Andrews
2017-02-21 17:30       ` Bart Schaefer
2017-02-21 19:57         ` Ray Andrews
2017-02-22  4:21           ` Bart Schaefer
2017-02-22  4:39             ` Ray Andrews

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).