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

trap inconsistency between platforms



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