[CDBUG-talk] Sysadmin blog

Dan Langille dan at langille.org
Mon Nov 17 16:36:19 EST 2014


> On Nov 16, 2014, at 9:59 PM, Jaime <jaime at snowmoon.com> wrote:
> 
> On Sun, Nov 16, 2014 at 9:39 PM, Brian Callahan <bcallah at devio.us> wrote:
>> So this reminds me of an oft-forgotten point in portability of shell
>> scripts: the popularity of the linuxism #!/bin/bash (though it appears it
>> has crept into Mac OS X as well, sad...).
> 
> I was aware of the down sides of hard-coding the path to the script's
> interpreter, but I wasn't aware of an alternative.  So thanks for
> sharing the /usr/bin/env tip.  I have two thoughts that I hope you're
> willing to hash-out with me, though.
> 
> 1)  Isn't the shebang that you suggested still hardcoded?  When the
> script is taken to a new OS, wouldn't there still be a risk of it
> breaking?  Has env just been in Unix for so long that its always in
> /usr/bin?
> 
> 2)  On MacOS, bash is always installed at /usr/bin/bash.  My script
> uses utilities specific to MacOS to modify configuration files
> specific to MacOS in order to ease MacOS deployment.  It is inherently
> irrelevent to other OSs and unable to move to another OS.  So is there
> a benefit to changing the shebang to env?

Code shell scripts with /bin/sh and avoid having to know where/if bash is installed.

This is especially important for scripts others will use.

— 
Dan Langille




More information about the CDBUG-talk mailing list