From owner-freebsd-questions@FreeBSD.ORG Thu Jan 26 04:34:29 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 84ED1106564A for ; Thu, 26 Jan 2012 04:34:29 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 4AB888FC14 for ; Thu, 26 Jan 2012 04:34:28 +0000 (UTC) Received: from pps.filterd (ltcfislmsgpa07 [127.0.0.1]) by ltcfislmsgpa07.fnfis.com (8.14.4/8.14.4) with SMTP id q0Q4RjfS017245; Wed, 25 Jan 2012 22:34:28 -0600 Received: from smtp.fisglobal.com ([10.132.206.17]) by ltcfislmsgpa07.fnfis.com with ESMTP id 12jvdmghq8-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 25 Jan 2012 22:34:28 -0600 Received: from [10.0.0.102] (10.14.152.28) by smtp.fisglobal.com (10.132.206.17) with Microsoft SMTP Server (TLS) id 14.1.323.3; Wed, 25 Jan 2012 22:34:27 -0600 MIME-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset="us-ascii" From: Devin Teske In-Reply-To: <8E97D656-0FC1-4DD5-9F94-6707823F9F12@mac.com> Date: Wed, 25 Jan 2012 20:34:25 -0800 Content-Transfer-Encoding: quoted-printable Message-ID: <7BBD45DF-B332-4719-8D05-B472A6D680F6@fisglobal.com> References: <28F1F479-EA39-4841-AE54-76F0E512C02B@mac.com> <912B3883-ABA1-4EE7-857B-CA8A55C8B506@polands.org> <4F20C759.7060508@herveybayaustralia.com.au> <8E97D656-0FC1-4DD5-9F94-6707823F9F12@mac.com> To: Chuck Swiger X-Mailer: Apple Mail (2.1084) X-Originating-IP: [10.14.152.28] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.6.7361, 1.0.211, 0.0.0000 definitions=2012-01-26_01:2012-01-26, 2012-01-26, 1970-01-01 signatures=0 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:34:29 -0000 On Jan 25, 2012, at 8:13 PM, Chuck Swiger wrote: > Hi-- >=20 > On Jan 25, 2012, at 7:24 PM, Da Rock wrote: >> On 01/26/12 12:55, Doug Poland wrote: >>> This gets me closer, but the scripts behave differently now on OS X. F= or example, printf's don't output the same. >>=20 >> Try searching on google and find out exactly what sh MacOSX is using. Th= en you'd have a better idea on what you're working with. >=20 > /bin/sh on MacOSX is: >=20 > $ /bin/sh --version > GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) > Copyright (C) 2007 Free Software Foundation, Inc. >=20 > ...and it has been using bash as /bin/sh since 10.2 or so. >=20 > Anyway, running bash as /bin/sh versus as /bin/bash likely affects whethe= r it invokes printf as a builtin(1) command or as an external command. It'= s possible that invoking /usr/bin/printf instead of just printf in the scri= pts might resolve the issue(s). >=20 If that's the problem, perhaps a "trick" can do: printf(){builtin printf "$@";} At the top after the she-bang. Should cause all invocations to use built-in= versus otherwise by defining a function that explicitly calls the built-in. --=20 Devin _____________ The information contained in this message is proprietary and/or confidentia= l. If you are not the intended recipient, please: (i) delete the message an= d all copies; (ii) do not disclose, distribute or use the message in any ma= nner; and (iii) notify the sender immediately. In addition, please be aware= that any message addressed to our domain is subject to archiving and revie= w by persons other than the intended recipient. Thank you.