Portability of shell scripts from other *nixes

Devin Teske devin.teske at fisglobal.com
Thu Jan 26 04:34:29 UTC 2012


On Jan 25, 2012, at 8:13 PM, Chuck Swiger wrote:

> Hi--
> 
> 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.  For example, printf's don't output the same.
>> 
>> Try searching on google and find out exactly what sh MacOSX is using. Then you'd have a better idea on what you're working with.
> 
> /bin/sh on MacOSX is:
> 
> $ /bin/sh --version
> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
> Copyright (C) 2007 Free Software Foundation, Inc.
> 
> ...and it has been using bash as /bin/sh since 10.2 or so.
> 
> Anyway, running bash as /bin/sh versus as /bin/bash likely affects whether 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 scripts might resolve the issue(s).
> 

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

_____________
The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.


More information about the freebsd-questions mailing list