Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jan 2012 20:34:25 -0800
From:      Devin Teske <devin.teske@fisglobal.com>
To:        Chuck Swiger <cswiger@mac.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Portability of shell scripts from other *nixes
Message-ID:  <7BBD45DF-B332-4719-8D05-B472A6D680F6@fisglobal.com>
In-Reply-To: <8E97D656-0FC1-4DD5-9F94-6707823F9F12@mac.com>
References:  <ac1be76b3dd10516e61861ae253b793f.squirrel@email.polands.org> <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>

next in thread | previous in thread | raw e-mail | index | archive | help

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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7BBD45DF-B332-4719-8D05-B472A6D680F6>