Pattern: Trapping ERR
is undefined
Issue: -
You are trying to install a trap that is not supported by your current shell (dash
or POSIX sh
). There is no simple replacement. The script should be rewritten to avoid depending on the trap, or simply be run with a shell that supports it.
Also applies to RETURN
and DEBUG
.
Example of incorrect code:
#!/bin/sh
trap 'Command failed with $?' ERR
Example of correct code:
#!/bin/bash
trap 'Command failed with $?' ERR