4 ms·
> Will this script ever run anywhere that I don't have the GNU toolchain? Effectively-0% likely. Not really. A lot of stuff broke when /bin/sh moved to a POSIX
by lamby 14y ago
> Will this script ever run anywhere that I don't have the GNU toolchain? Effectively-0% likely.
Not really. A lot of stuff broke when /bin/sh moved to a POSIX-compatibile shell rather than Bash.
- njharman 14y agoNo a lot of stuff broke because people depended on implicit rather than being explicit. #!/bin/bash
- Wilya 14y agowilya@home $ /bin/bash zsh: no such file or directory: /bin/bash wilya@home $ which bash /usr/local/bin/bash (Yes, I'm annoyed when I see #!/bin/bash, especially on scripts which are otherwise basic enough to be portable everywhere)
- dfox 14y agoIt is still better to write #!/bin/bash for bashism using scripts than #!/bin/sh. I recently had to run sed -i (well, another GNUism) 1s%/sh%/bash% on bunch of customer's scripts to make them work on debian. At least when script wants /bin/bash it is going to fail cleanly (and not in the middle after modifying random things) and with mostly meaningful error.
- wollw 14y agoIt's probably safer to use: #!/usr/bin/env bash Assuming env is installed (I believe I had to install a package on OpenBSD to use it) this will find the first instance of bash in the PATH.
- atsaloli 14y agoHow do you know env is in /usr/bin rather than in /bin or /usr/local/bin? I'm just curious...