Bash vs sh Shebangs

Discussions center on the use of #!/bin/bash versus #!/bin/sh in shell script shebangs, debating portability, POSIX compliance, bashisms, and system differences like dash or env usage.

➡️ Stable 0.5x Programming Languages
4,289
Comments
19
Years Active
5
Top Authors
#796
Topic ID

Activity Over Time

2008
5
2009
43
2010
50
2011
92
2012
144
2013
155
2014
315
2015
186
2016
172
2017
162
2018
241
2019
265
2020
379
2021
444
2022
413
2023
394
2024
419
2025
375
2026
37

Keywords

manual.m CMD PATH JS OSH POSIX oils.pub ENTRYPOINT QuickServ OS bash bin sh shell usr posix env scripts portable scripting

Sample Comments

I said /bin/sh, not /bin/bash.

Athas Nov 1, 2021 View on HN

Not all systems have bash as /bin/bash. A shebang line of '#!/usr/bin/env bash' would be even more portable.

pvinis Mar 19, 2021 View on HN

It was with bash, not sh. Hm interesting.

tempodox Nov 8, 2021 View on HN

Not for shellcheck(1). It warns about bashisms if it sees `/bin/sh` after the hash-bang.

justincormack Sep 25, 2014 View on HN

have you pointed /bin/sh and /bin/bash at it?

chillfox Nov 8, 2021 View on HN

Why make it bash specific instead of sh?

hashhar Dec 27, 2016 View on HN

That's a bashism I think and hence not as portable as POSIX shells.

necrodawg Feb 11, 2015 View on HN

Most of the time /bin/sh would suffice as no bash features are used but people still use /bin/bash.

VWWHFSfQ May 18, 2023 View on HN

Pray for all those scripts out there that assume /bin/sh or /bin/bash exists. Sounds like they only have a couple more years of error-free life

felixgallo Sep 27, 2014 View on HN

It's not shell scripts, it's /bin/bash -- the guy fieri of shells.