libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ltmain.in - why no shell functions?


From: Tim Mooney
Subject: Re: ltmain.in - why no shell functions?
Date: Mon, 23 Jul 2001 13:00:09 -0500 (CDT)

In regard to: ltmain.in - why no shell functions?, John Reiser said (at...:

>ltmain.sh (GNU libtool) 1.4 (1.920 2001/04/24 23:26:18)
>-----libtool.info-4:
>   Then in `ltmain.in' ...  This is the real code... I wish I could
>condense it a little more, but I don't think I can without function
>calls.
>-----
>
>Why not use shell functions?

The traditional Bourne shell was not required to have shell functions,
so many vendor's versions of the Bourne shell didn't.  Shell functions
were backported into the Bourne shell by some vendors after they became
popular (mainly because of ksh).

These days, it's difficult to tell whether you'll get a somewhat-traditional
Bourne shell or the POSIX shell when you do

        #! /bin/sh

I tested a simple function on half a dozen platforms.  AIX 4.2.x, HP-UX 10.20,
and IRIX 6.5.x all have a /bin/sh that has functions.  Solaris 2.6 & 2.8,
Tru64 UNIX 5.x, and FreeBSD 4.2 all have shells that don't hack functions.
In FreeBSD's case, it's because they use `ash' as /bin/sh.  For Solaris and
Tru64, it's because they have a traditional /bin/sh.  Both of those
platforms do provide an implementation of the POSIX shell, but that's *not*
what you get when you run /bin/sh.

You're right that shell functions can be handled by *some* Bourne-like
shell on virtually all *recent* platforms.  It's not as simple as just using
/bin/sh everywhere, though.  The farther back you wish to support (SunOS 4.1.4
and HP-UX 9.x are still widely used), the more difficult it becomes.

If you care about portability, you avoid shell functions *if* you're going
to hardcode /bin/sh as the shbang interpreter.  If you're using autoconf
to probe your system for features and functionality, you could substitute
in a path to a shell that supports functions, or error out if you can't
find one.

Tim
-- 
Tim Mooney                              address@hidden
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164




reply via email to

[Prev in Thread] Current Thread [Next in Thread]