[Top][All Lists]

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

Re: GNU Make on Linux Feeding All Commands Through ksh

From: Philip Guenther
Subject: Re: GNU Make on Linux Feeding All Commands Through ksh
Date: Wed, 8 Oct 2008 15:26:53 -0700

On Wed, Oct 8, 2008 at 2:47 PM, David Boyce <address@hidden> wrote:
> On Wed, Oct 8, 2008 at 4:13 PM, Steve Waltner <address@hidden> wrote:
> For the record - though this seems to be a false trail - that's not
> _exactly_ what I'm saying. GNU make always[1] uses the "system shell"
> by default, and on Unix the system shell is always the binary found at
> /bin/sh. POSIX requires the system shell to have ksh-like semantics
> but compatibility requires it to have traditional Bourne-shell
> semantics. <...>

Actually, POSIX does not require "/bin/sh" to have any particular
behavior.  It just requires that when running in a POSIX conformant
mode---which may involve particular a PATH setting---the command found
when "sh" is invoked behave as required by the standard (aka "ksh-like

> Still, the ball is in your court to figure out how GNU make could
> possibly be skipping the shell when SHELL has been overridden since it
> just doesn't do that.

I believe GNU make is *not* skipping the shell.  Instead, ksh on
Solaris has the quirk that when invoked with the -c option, it
automatically uses 'exec' to invoke the final command in the supplied
command list.  That saves a process without otherwise affecting the

> Another thing to consider is to just strip out the SHELL override on
> Linux (or everywhere if that works). Solaris /bin/sh is very old so
> there's a good chance SHELL was promoted to ksh only to work around a
> bug or limitation in it. Linux /bin/sh is really a link to bash which
> is 15-20 years newer and has a great deal of ksh compatibility built
> in [2], so it might "just work" without the override.
> [2] However, note that bash runs in a Bourne-compatible mode when used
> as /bin/sh which means some features are not available.

Almost: when run as "sh", bash enables 'posix' mode, so as long as
they don't require ksh features that were left out of the standard,
they should be fine with that and I agree that that's a good idea.

(A true "Bourne-compatible" mode would leave out stuff like $(command)
and $((expression)).)

> One other thing: if you are really going wth GNU make across the
> board, as opposed to the native make, you should assign SHELL (and
> most other variables) with the := syntax e.g. "SHELL := /bin/ksh".
> This is more efficient but a GNU-only feature.

How would that have any performance effect when the value is a simple
string without any variable or function references?

(I have a vague memory that internally, "foo:=bar" is converted to
"foo=bar" by expanding 'bar' and then replacing $s in the result with
$$ so that the normal delayed expansion gives the normal result.
I.e., for simple strings it involves *more* work, not less!)

Philip Guenther

reply via email to

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