Recently Written · git

tmpl

Insanely simple templates

git clone https://github.com/equwal/tmpl

Log | Files | Refs


sh/trap/error-handler (347 bytes)

1 # Exit on error with context
2 set -e
3 
4 error_handler() {
5     echo "Error on line $1: Command failed with status $2" >&2
6     <++>
7     exit $2
8 }
9 
10 # Note: ERR trap is bash-specific. In POSIX sh, use manual error checking:
11 # command || { error_handler $LINENO $?; }
12 # For automatic error handling in POSIX sh, you'll need to wrap commands manually
13 
14 <++>