From owner-freebsd-questions@FreeBSD.ORG Thu Jan 26 12:36:51 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 1C8DA106564A for ; Thu, 26 Jan 2012 12:36:51 +0000 (UTC) (envelope-from jerry@seibercom.net) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id BD9298FC12 for ; Thu, 26 Jan 2012 12:36:50 +0000 (UTC) Received: by yhfs35 with SMTP id s35so203487yhf.13 for ; Thu, 26 Jan 2012 04:36:50 -0800 (PST) Received: by 10.236.138.131 with SMTP id a3mr2679629yhj.101.1327581410072; Thu, 26 Jan 2012 04:36:50 -0800 (PST) Received: from scorpio.seibercom.net (cpe-076-182-104-150.nc.res.rr.com. [76.182.104.150]) by mx.google.com with ESMTPS id p63sm6539687yhj.22.2012.01.26.04.36.48 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jan 2012 04:36:49 -0800 (PST) Received: from scorpio (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jerry@scorpio.seibercom.net) by scorpio.seibercom.net (Postfix) with ESMTPSA id 3TYjRg5QyRz2CG4h for ; Thu, 26 Jan 2012 07:36:47 -0500 (EST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.97.3 at scorpio.seibercom.net Date: Thu, 26 Jan 2012 07:36:47 -0500 From: Jerry To: FreeBSD Message-ID: <20120126073647.34f2dedb@scorpio> In-Reply-To: References: Organization: seibercom.net X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.6; amd64-portbld-freebsd8.2) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAHlBMVEUAAABYRlwJCw4FAgAIBwKprDkBAQFQLR0BAgCir7VRttp8AAACAUlEQVQ4jZWUTYvbMBCGTVl8V2hX6Gg5G5FbWQdBj0lEfE7BhN4cyzi5Wt1E5L70roWy6N92xok/skkP+5IYrMcz78xIduDWpNM3vFzuA/jX5EY1AI6KHFwW/CzFuQAwqUBbV12p+CzIh6Awq7sg33pn5D64SQXAexffeuQlA/L35RrkaB551OjGfP/cAO8mCNaDcgvfky5ijoD0pAXlCQCnljiAjsJD9Ax05Ko5sZxbnLQcmM+dZg5IjREfZrWIHK0JuwU68pAGwHvfRxBundRzTxxz3r9dNUikPsEihjz2Dc4kjp1hKsJGuot4EDxaxzMoC7XqhxhOSfZrTS6gSX1JVdjp+o1PvWfekXgw3WL0g70nDEwA0H0HQsEZc8sTmFMTkWUfYWC/vdR1zQy3xLQgLwzu90QnlnFLjeiGWBjwhb4Sa42IqOg2qqS4O1/zhKokFUb1Q8Rj4Eb69WVflXEehJ35DgChVTE5n50eaGyMLOfH8AOodoSM4PVYAQgQdBulOa+knklYks3vAuQ+uX492lTl+A+e8qBV2AKoXalVKFfyuUp0pUp1ARaUHh82lv9MN+Ig7CZtgE6FNYvjlywT2VP2dMgOG46gTIWcqdfvuwyXNz0oMJNd/N5lh1YNiJt19ADTUo3VuFSNeQwVqRSrGjSCp53fk2g+Mvfk/gfoPxHeUS8MH9vRAAAAAElFTkSuQmCC Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: Portability of shell scripts from other *nixes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: FreeBSD List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Jan 2012 12:36:51 -0000 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