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'.

📉 Falling 0.3x Programming Languages
4,276
Comments
19
Years Active
5
Top Authors
#6860
Topic ID

Activity Over Time

2008
7
2009
25
2010
25
2011
68
2012
113
2013
119
2014
283
2015
169
2016
223
2017
227
2018
205
2019
209
2020
455
2021
529
2022
466
2023
448
2024
399
2025
281
2026
25

Keywords

e.g linux.die tldp.org manipulation.html undeadly.org ShellCheck redsymbol.net NUL GP SQL shell bash script awk shell script string oil inline strict variable

Sample Comments

cmeacham98 Dec 23, 2024 View on HN

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.

NackerHughes Oct 7, 2022 View on HN

Short answer: because it's Bash. No syntax or language construct will do what you expected.

webstrand Nov 22, 2024 View on HN

There's now an issue for it https://github.com/koalaman/shellcheck/issues/3088

rascul Mar 22, 2022 View on HN

https://mywiki.wooledge.org/BashFAQ/112

asicsp Dec 10, 2021 View on HN

Relevant: https://mywiki.wooledge.org/ArgumentsSee also: https://mywiki.wooledge.org/BashFAQ and https://mywiki.wooledge.org/BashPitfalls

rando289 Aug 16, 2015 View on HN

We've overwhelmed it. Instead: https://web.archive.org/web/20150811151807/http://mywiki.woo...

CyberShadow Jan 24, 2022 View on HN

ShellCheck agrees:https://github.com/koalaman/shellcheck/wiki/SC3003

odc Aug 15, 2014 View on HN

Does it work better than bash -n?

l0b0 Nov 23, 2023 View on HN

See https://mywiki.wooledge.org/BashFAQ/031

lloeki Jul 7, 2023 View on HN

There's an issue already about it: https://github.com/koalaman/shellcheck/issues/760