bashstyle icon indicating copy to clipboard operation
bashstyle copied to clipboard

Let's do Bash right!

Results 18 bashstyle issues
Sort by recently updated
recently updated
newest added
trafficstars

http://www.shellcheck.net/ is a linter for Bash that covers a lot of this (and more, too). repo at https://github.com/koalaman/shellcheck

What's the preferred style for documenting functions? ``` bash a() { # a does foo ... } # b does foo b() { ... } c() { # c does...

Statements joined with `&&` don't end a script even when it's running with `set -e`, but if they're the last statement in your file, their non-zero exit code will be...

considering

(This is a best practice that sort of runs into the "protips" area, one that applies more in Plushu or Dokku than it does to most Bash scripts.) ## Ownership...

If you don't assert the existence of certain important variables, your script could inadvertently wipe the user's home directory: https://github.com/ValveSoftware/steam-for-linux/issues/3671 https://news.ycombinator.com/item?id=8896186

This is one of those holes that can open up if you're not being conscious of how you're outputting your strings. If it could have spaces, quotes, or dollar signs...

considering

# Setting LC_ALL=C See http://unix.stackexchange.com/questions/87745/what-does-lc-all-c-do If you don't set LC_ALL=C for, say, sorting a list of numbers from a container/network source, it's going to be dependent on the system locale....

Since this is apparently a somewhat obscure tool for a _very necessary_ task (converting strings to argument lists while preserving quoting/grouping), I think it's called for to have a note...