[CDBUG-talk] Sysadmin blog

James L. Lauser james at jlauser.net
Mon Nov 17 18:20:41 EST 2014


That assumes you don't do a common Linuxism and assume that sh is actually
bash or something else and write a script that depends on a feature that's
not common to all sh-like shells.

--  James L. Lauser
    james at jlauser.net
    http://jlauser.net/
On Nov 17, 2014 4:58 PM, "Dan Langille" <dan at langille.org> wrote:

>
> > 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
>
>
> _______________________________________________
> CDBUG-talk mailing list
> CDBUG-talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/cdbug-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/cdbug-talk/attachments/20141117/c9a8318b/attachment.html>


More information about the CDBUG-talk mailing list