A shebang names the interpreter; the forms differ in where they look.
#!/bin/bash runs the binary at that exact path: Bash features work — arrays, [[ ]], brace expansion, source — but it breaks where Bash is absent or elsewhere: minimal containers, some BSDs.
#!/usr/bin/env sh asks env to find sh on the user’s PATH, so it runs under whatever sh is — dash on Ubuntu, bash in POSIX mode, else something else. Portable, POSIX features only. Same for #!/usr/bin/env bash: it finds a Bash, not a specific one.
| Shebang | Use when |
|---|---|
#!/bin/bash | the script needs Bash features and you control the environment |
#!/usr/bin/env sh | portability matters and POSIX is enough |
Rule: CI, container or system scripts get #!/usr/bin/env sh; developer scripts using arrays or [[ ]] get #!/bin/bash.
Failure is quiet: a #!/usr/bin/env sh script using [[ ]] works where sh is a Bash symlink, fails on Debian where it is dash.