2 ms·
I long adopted /bin/sh -eu header in my scripts. It's a must-have.
by vbezhenar 5y ago
I long adopted
/bin/sh -eu
header in my scripts. It's a must-have.
- CyberShadow 5y agoIf you mean as a shebang (#!/bin/sh -eu), I would suggest switching to using "set" instead, because the shebang will not be interpreted if the script is ran as "sh script.sh" (as opposed to ./script.sh).
- kop316 5y agoPerdon my ignorance, but what do those do? Searching for it doesn't give me anything.
- Symbiote 5y agoSee https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin https://www.gnu.org/software/bash/manual/bash.html#The-Set-B..., in short -e makes scripts exit if a command fails, and -u makes them exit if a variable is undefined. If you think your colleagues won't know this, "set -o errexit; set -o nounset" would be easier for them to search on. (Via "3.4 Shell Parameters" → "3.4.1 Positional Parameters" → "4 Shell Builtin Commands", or searching the whole page for "-e".)
- kop316 5y agoThank you very much, I appreciate it.