In perl, you can exit with an error msg with die \"some msg\". Is there an equivalent single command in bash? Right now, I\'m achieving this using commands: <
die \"some msg\"
Here's what I'm using. It's too small to put in a library so I must have typed it hundreds of times ...
warn () { echo "$0:" "$@" >&2 } die () { rc=$1 shift warn "$@" exit $rc }
Usage: die 127 "Syntax error"
die 127 "Syntax error"