Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
trap inconsistency between platforms
- X-seq: zsh-users 22694
- From: Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: trap inconsistency between platforms
- Date: Sat, 13 May 2017 16:18:52 +0200
- 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
Hi,
the below code fragment generates...
TRAPPED ON ERROR
TRAPPED ON EXIT
...on Cygwin, Linux and macOS with Bash and on Cygwin
and macOS with Zsh.
On Linux with Zsh it only generates...
TRAPPED ON ERROR
```
# will also run on error (except with zsh on Linux)
exit_handler() { echo "TRAPPED ON EXIT"; }
error_handler() {
error_code=$?
echo "TRAPPED ON ERROR"
exit $error_code
}
trap exit_handler EXIT
trap error_handler ERR
false
```
Cygwin 2.8.0, zsh 5.3.1, bash 4.4.12
Ubuntu 17.04, zsh 5.2, bash 4.4.5
macOS Sierra, zsh 5.3.1, bash 4.4.12
Thorsten
Messages sorted by:
Reverse Date,
Date,
Thread,
Author