From owner-freebsd-questions@FreeBSD.ORG Thu Jan 26 04:27:05 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 56446106566C for ; Thu, 26 Jan 2012 04:27:05 +0000 (UTC) (envelope-from mikel.king@olivent.com) Received: from mail.olivent.com (mail.olivent.com [75.99.82.91]) by mx1.freebsd.org (Postfix) with ESMTP id AF8498FC0A for ; Thu, 26 Jan 2012 04:27:04 +0000 (UTC) Received: from localhost ([127.0.0.1]) by mail.olivent.com (Kerio Connect 7.0.0 patch 1) (using TLSv1/SSLv3 with cipher AES128-SHA (128 bits)); Wed, 25 Jan 2012 23:26:52 -0500 Mime-Version: 1.0 (Apple Message framework v1084) From: mikel king X-Priority: 3 (Normal) In-Reply-To: Date: Wed, 25 Jan 2012 23:26:44 -0500 Message-Id: <38FBA444-16B3-4C38-8801-AB63E7AA5F7A@olivent.com> References: To: Doug Poland X-Mailer: Apple Mail (2.1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: Portability of shell scripts from other *nixes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jan 2012 04:27:05 -0000 On Jan 25, 2012, at 5:08 PM, Doug Poland wrote: > Hello, >=20 > I'm trying port some shell scripts to FreeBSD that were originally > written on Darwin (OS X). >=20 > 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. >=20 > 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. >=20 >=20 > --=20 > 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