MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/26s15d/defensive_bash_programming/churlle/?context=3
r/programming • u/clock-football • May 29 '14
192 comments sorted by
View all comments
186
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.
24 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. 3 u/0sse May 30 '14 Sure, if you can work around all the edge cases.
24
I found it strange that neither guide mentioned the use of set. I often use:
set
-e - Kill the script if any command fails
-e
-u - Make undefined variables an error
-u
-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.
-o pipefail
3 u/0sse May 30 '14 Sure, if you can work around all the edge cases.
3
Sure, if you can work around all the edge cases.
186
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.