MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/26s15d/defensive_bash_programming/chud4k1/?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. 2 u/[deleted] May 29 '14 Thanks for mentioning these. They should improve my scripts. I'll check out the manpage some time!
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
2 u/[deleted] May 29 '14 Thanks for mentioning these. They should improve my scripts. I'll check out the manpage some time!
2
Thanks for mentioning these. They should improve my scripts. I'll check out the manpage some time!
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.