3 ms·
I've been doing my scripts for decades on various, numerous, Linux and UNIX systems, real and virtual machines and never used env shell nor have I seen "set -e
by LoveGracePeace 5y ago
I've been doing my scripts for decades on various, numerous, Linux and UNIX systems, real and virtual machines and never used env shell nor have I seen "set -euo pipefail" and have had zero issues.
Saying "The first two lines of the script are already wrong;" is wrong. Is that better? IDK, maybe. But "#!/bin/bash" works fine.
- LeoPanthera 5y ago> "#!/bin/bash" works fine It doesn't work at all on any BSD OS, which does not store bash in /bin - instead it is in /usr/local/bin Specifying "env bash" makes it work on any UNIX, since the location of env is a constant, unlike bash.
- deckard1 5y agodoes it matter? MacOS is using some ancient ass 3.x bash from 2007. The location of bash is the least of your worries when it comes to portability. There's no guarantee any of the commands in your script (a) exist on the system or (b) work with the same options and flags that the script uses. I don't even know how many "netcat" commands I've seen in the wild. You could be running in some BusyBox or pared down Docker container. Blindly running a script that hasn't been deliberately crafted to work on your system is just asking for trouble.
- mekster 5y agoYou call 2007 ancient when bash has been around for over 30 years? What exactly has changed in the last 15 years?