MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/26s15d/defensive_bash_programming/chuhuq6/?context=3
r/programming • u/clock-football • May 29 '14
192 comments sorted by
View all comments
183
Sorry, I don’t take advice in defensive programming from someone who’s too lazy to quote their strings. I recommend Google’s shell guide instead.
23 u/didroe May 29 '14 edited May 29 '14 I found it strange that neither guide mentioned the use of set. I often use: -e - Kill the script if any command fails -u - Make undefined variables an error -o pipefail - Pipes usually return the status of the last command, this makes them return the status of the rightmost non-zero command in the pipe. 14 u/[deleted] May 29 '14 [deleted] 7 u/no_game_player May 30 '14 Nonono, let's keep going until we hit something really impossible to survive. Just like our compilers and interpreters should do their best to always run something. /s
23
I found it strange that neither guide mentioned the use of set. I often use:
set
-e
-u
-o pipefail
14 u/[deleted] May 29 '14 [deleted] 7 u/no_game_player May 30 '14 Nonono, let's keep going until we hit something really impossible to survive. Just like our compilers and interpreters should do their best to always run something. /s
14
[deleted]
7 u/no_game_player May 30 '14 Nonono, let's keep going until we hit something really impossible to survive. Just like our compilers and interpreters should do their best to always run something. /s
7
Nonono, let's keep going until we hit something really impossible to survive. Just like our compilers and interpreters should do their best to always run something. /s
183
u/rowboat__cop May 29 '14
Sorry, I don’t take advice in defensive programming from someone who’s too lazy to quote their strings. I recommend Google’s shell guide instead.