Date: Wed, 25 Jan 2012 23:26:44 -0500 From: mikel king <mikel.king@olivent.com> To: Doug Poland <doug@polands.org> Cc: freebsd-questions@freebsd.org Subject: Re: Portability of shell scripts from other *nixes Message-ID: <38FBA444-16B3-4C38-8801-AB63E7AA5F7A@olivent.com> In-Reply-To: <ac1be76b3dd10516e61861ae253b793f.squirrel@email.polands.org> References: <ac1be76b3dd10516e61861ae253b793f.squirrel@email.polands.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 25, 2012, at 5:08 PM, Doug Poland wrote: > Hello, > > I'm trying port some shell scripts to FreeBSD that were originally > written on Darwin (OS X). > > The issue I'm having is the shebang line of the scripts in OS X is > #!/bin/sh, and it turns out that is really an instance of bash, and > the code contains some bashisms. On FreeBSD I have bash in > /usr/local/bin/bash. > > Is there an "easy/best" way to have a single shebang that works on > both OS's? I'd rather not change FreeBSD's bourne shell to bash with > any symlinking of /usr/local/bin/bash to /bin/sh. > > > -- > Regards, > Doug Mac OS X defaults to /bin/bash but things get weird because sh on mac is also bash. Funnily enough a complete separate binary and not a symlink. Anyway, this means things written for the Mac may not work directly on FreeBSD. What I mean is that bash3 syntax is not going to be backwardly compatible with sh. If you wish to retain the bashiness of the scripts then the easiest option would be to install the bash (3.x) port and use env to invoke the appropriate shell on each system. Regards, Mikel King BSD News Network http://bsdnews.net skype: mikel.king http://twitter.com/mikelking
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38FBA444-16B3-4C38-8801-AB63E7AA5F7A>
