Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Jan 2012 07:36:47 -0500
From:      Jerry <jerry@seibercom.net>
To:        FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: Portability of shell scripts from other *nixes
Message-ID:  <20120126073647.34f2dedb@scorpio>
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 Wed, 25 Jan 2012 16:08:07 -0600
Doug Poland articulated:

> 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.

I have written several scripts for use on different OSs, all written in
Bash since that is my preferred scripting language, and have used this
as the shebang quite effectively:

	#!/usr/bin/env bash

By the way, what version of Bash? If it is v4.x there are many
improvements that do not work on older v3.x and v2.x versions. 

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________
Religion is the anthropomorphization of reality, that behind it all
there's an invisible man pulling invisible strings



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120126073647.34f2dedb>