[colug-432] Portable Shell

Rob Funk rfunk at funknet.net
Mon Oct 19 10:40:51 EDT 2015


Rick Hornsby wrote:
> > On Oct 19, 2015, at 05:48, Mike Plemmons <mikeplemmons at gmail.com> wrote:
> > 
> > There are plenty of people on this list with more experience
> > across a wider range of UNIX/Linux but I think Bash is your safest bet.

If you want to go beyond Linux, bash is not a safe bet at all.

> One of the biggest shell script portability issues I've run into -
> going between Linux and OS X (BSD variant) - is not with bash itself,
> but with tools like sed being slightly different.  The solution on OSX
> is to use the gnu tools (i.e. gsed) from homebrew - but it's confusing
> until you know that's what's happening.

But you can't rely on Homebrew being installed. Even the OSX people
who install package managers are divided between Homebrew, Macports,
and Fink. (I'd choose Macports myself.) And not everyone bothers to
install one of those, or the utilities you might be relying on.

For portability, better to assume only the default tools are there,
and deal with that. That means don't use any GNU extensions.


One useful approach might be to pick up a copy of "The Unix
Programming Environment" (1984), and write to what's specified there.



More information about the colug-432 mailing list