Bash Scripting Pitfalls
Discussions center on common Bash-specific issues like bash-isms, quoting problems, globbing, and unexpected behaviors, with references to ShellCheck warnings, BashFAQ, BashPitfalls, and strict mode recommendations such as 'set -ue -o pipefail'.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Fair warning - this is a bash-ism, so if you're writing a script that needs to run on multiple shells and/or a more primitive shell, you should avoid it.
Short answer: because it's Bash. No syntax or language construct will do what you expected.
There's now an issue for it https://github.com/koalaman/shellcheck/issues/3088
https://mywiki.wooledge.org/BashFAQ/112
Relevant: https://mywiki.wooledge.org/ArgumentsSee also: https://mywiki.wooledge.org/BashFAQ and https://mywiki.wooledge.org/BashPitfalls
We've overwhelmed it. Instead: https://web.archive.org/web/20150811151807/http://mywiki.woo...
ShellCheck agrees:https://github.com/koalaman/shellcheck/wiki/SC3003
Does it work better than bash -n?
See https://mywiki.wooledge.org/BashFAQ/031
There's an issue already about it: https://github.com/koalaman/shellcheck/issues/760