Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
trap ERR
- X-seq: zsh-users 22477
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: trap ERR
- Date: Mon, 20 Feb 2017 22:08:09 -0800
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author