Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by vbezhenar on Thursday December 30, 2021 @08:08AM
(#29736395)
I long adopted
header in my scripts. It's a must-have.
[ Parent
| on HN ]
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by CyberShadow on Thursday December 30, 2021 @08:50AM
(#29736664)
If 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).
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by kop316 on Thursday December 30, 2021 @08:57AM
(#29736700)
Perdon my ignorance, but what do those do? Searching for it doesn't give me anything.
Re:Japan HP accidentally deleted 77TB data in Kyoto U. super...
by Symbiote on Thursday December 30, 2021 @09:32AM
(#29736974)
See 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".)