2 ms·
I almost always use set -e with my bash scripts; this way you will always notice if an invoked command failed or not; your script will not report that everythin
by MichaelMoser123 13y ago
I almost always use set -e with my bash scripts;
this way you will always notice if an invoked command failed or not; your script will not report that everything is OK if part of the process actually failed.
https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html#The-Set-Builtin https://www.gnu.org/software/bash/manual/html_node/The-Set-B...
Also: set -x is the best debugger in the world; really.
- MichaelMoser123 13y agoAlso useful trick is to have exit traps, doing stuff on exit. http://linux.die.net/Bash-Beginners-Guide/sect_12_02.html http://linux.die.net/Bash-Beginners-Guide/sect_12_02.html
- penguindev 13y agoYeah, surprised that got no mention. I thought the ./* wildcarding for safety was really cool. they also could have covered find -print0 | xargs -0 for safety. I'm glad they talked about "$@" being usually always the right thing to do. That's been a hard won learning experience for me in the past...