Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> shbang'd to bash.

Good.

Better: #!/bin/sh

Best: #!/bin/sh and also not assuming bash anyway!



I wouldn't say putting a sh shebang and assuming bash is better. With a bash shebang at least you're honest about it.


Well yes, absolutely. I phrased that poorly, what I meant was like '/bin/sh is better... Especially if it actually works' or something.

It's easily done though, I've often thought I've written something POSIX compatible and then had shellcheck say nope.


Best would actually be

#!/usr/bin/env sh

Since this binary is required by the POSIX standard to exist at that location.


Oh and how /bin/bash is bash3 on macOS instead of the contemporary bash5 by default. And how sh is dash on Debian, or Ubuntu, I forgot. Some of the reasons why I would prefer python3 scripts (or perl) over sh or bash


Pretty annoying to reliably #! to python3 as well. Is it /usr/bin/python or python3?


That's my worst. I think generally python3 is safe (if unnecessary) today? But for how long do we have to keep that around?

Can we now say Well python2 is EOL so python should certainly be v3+?

It is of course a more general issue with shebangs that it's a very loose 'dynamically linked' coupling, not necessarily judt affecting language version but environment/libraries too, it just seems particularly problematic or prevalent with python.


/usr/bin/env python3


That's not the point - 'or /usr/bin/env python?'



If we're distributing software, maybe? Personally we control the hardware, so we know what we're running, but yeah, for libraries or packages this makes sense.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: