[Top][All Lists]

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

Handling of SHELL by GNU make: not POSIX compliant

From: psmith
Subject: Handling of SHELL by GNU make: not POSIX compliant
Date: Wed, 25 Sep 2002 14:08:12 -0400

%% David Boyce <address@hidden> writes:

  db> 1. Why does GNU make automatically export settings of SHELL
  db>    without the 'export' keyword?
  db> 2. The unexport directive should not *remove* SHELL from the environment 
  db>    but rather just suppress the export of the internal variable.

I don't know the answer to #1, really.

Originally I thought it might be required by POSIX, but actually looking
at the POSIX spec now I think maybe GNU make is wrong, and is not
conforming to the standard--that's why I'm forwarding this message to
make-alpha so others can comment.

The POSIX 1003.1-2001 "Shell and Utilities, Issue 6" spec (page 614,
lines 23699-23704) says:

  The SHELL macro shall be treated specially.  It shall be provided by
  make and set to the pathname f the shell command language interpreter
  (see sh).  The SHELL environment variable shall not affect the value
  of the SHELL macro.  If SHELL is defined in the makefile or is
  specified on the command line, it shall replace the original value of
  the SHELL macro, *but shall not affect the SHELL environment variable*.
  Other effects of defining SHELL in the makefile or on the command line
  are implementation-defined.

(emphasis mine).  So, it seems GNU make is not handling this properly,
since any setting of the make variable SHELL _is_ reflected in the
environment variable.

So, what do people on make-alpha think?  Are there good reasons for the
current behavior of make WRT the SHELL variable?  What kind of
backward-incompatibilities might be introduced if we changed the default
behavior of GNU make to match the standard?  Would the be egregious
enough that we should consider enabling this behavior only if the .POSIX
special target is defined?  The POSIX definition, however, seems to
leave no method of actually _setting_ the SHELL environment variable, if
you should want to do that; should we provide some method of doing this
(David suggests that if you _explicitly_ export SHELL in your makefile,
then it would use that value in the environment).

If we don't change the default behavior, what do we do for people (like
David) who want to set a different value for SHELL so that make uses
some other script, but _don't_ want to change the value of SHELL in the
environment of their children?

Right now you _CAN_ work around this with something like:

In the makefile:

  export ORIG_SHELL := $(SHELL)

  SHELL := /my/script

In /my/script:


or whatever syntax is necessary.  Is this good enough?

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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