And I'm saying just don't do that! If you use #!/bin/sh, it won't work, so don't use #!/bin/sh! You're writing Bash, so use #!/bin/bash! Because it's Bash. Not sh.
Bash and POSIX sh are different languages. If you write a script in language A, but try to run it as language B, it obviously won't work! And it's your own stupid fault for trying. Why is this such a difficult concept?
Literally I do not understand, why people write something in Bash then put the wrong shebang line at the top, on purpose. And then it doesn't work right, and then they act like this is a problem with Bash. Instead of their own fault, for trying to execute it with the wrong interpreter. Like .. just stop punching yourself in the face on purpose! Stop being stupid!
Bash developed before POSIX.2, so the old behavior of bash that is incompatible is suppressed when it runs as #!/bin/sh or when POSIX mode is otherwise set.
My particular bugbear is "alias p=printf" which works in scripts when bash is /bin/sh but fails when it is /bin/bash.
This is because bash historically did not honor alias in scripts. The solution is to set POSIX mode.
So, you see, there are two bash shells, and you likely do not know know the pre-POSIX shell as well as you might think.
And I'm saying just don't do that! If you use #!/bin/sh, it won't work, so don't use #!/bin/sh! You're writing Bash, so use #!/bin/bash! Because it's Bash. Not sh.
Bash and POSIX sh are different languages. If you write a script in language A, but try to run it as language B, it obviously won't work! And it's your own stupid fault for trying. Why is this such a difficult concept?
Literally I do not understand, why people write something in Bash then put the wrong shebang line at the top, on purpose. And then it doesn't work right, and then they act like this is a problem with Bash. Instead of their own fault, for trying to execute it with the wrong interpreter. Like .. just stop punching yourself in the face on purpose! Stop being stupid!