Portability of shell scripts from other *nixes

Chuck Swiger cswiger at mac.com
Thu Jan 26 04:14:07 UTC 2012


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


More information about the freebsd-questions mailing list