-
Notifications
You must be signed in to change notification settings - Fork 0
die
zeta709 edited this page Jan 24, 2022
·
3 revisions
die() { printf '%s\n' "${1-}"; exit 1; }See https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo or echo.md.
Because it's the simplest. According to the document above, you need to set IFS for the best reliability.
However, I personally think they are overkill for a simple die function: creating a subshell would cause overhead; defining a little bit complex echo function seems inelegant. Why would you bother yourself? Just accept one argument for your die function.