Defensive BASH programming
kfirlavi.com
Defensive BASH programming
1–10 of 53 posts
Re: Defensive BASH programming
#2Re: Defensive BASH programming
#3Re: Defensive BASH programming
#4I think the best "defensive" piece of advice you left out that everyone abuses is never pipe `find` results to `xargs.` One should always do `find ... -print0` to a read-while loop because of filenames with whitespace.
Re: Defensive BASH programming
#5I've been enjoying BATS [0] for my bash testing.
Re: Defensive BASH programming
#6I think the best "defensive" piece of advice you left out that everyone abuses is never pipe `find` results to `xargs.` One should always do `find ... -print0` to a read-while loop because of filenames with whitespace.
`find -print0 | xargs -0 grep some_pattern'
Re: Defensive BASH programming
#7Re: Defensive BASH programming
#8Re: Defensive BASH programming
#9All these recommendation are excellent (except omitting the necessary obsessive quoting of all variables everywhere (just in case they contain a space). I've been enjoying BATS [0] for my bash testing. [1] https://github.com/sstephenson/bats