[Top][All Lists]

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

Re: [Axiom-developer] ENV

From: Gabriel Dos Reis
Subject: Re: [Axiom-developer] ENV
Date: 22 Nov 2006 20:26:09 +0100

Humberto Ortiz Zuazaga <address@hidden> writes:

| Gabriel Dos Reis wrote:
| > Nobody claims that is illegal.  We are talking of a *specific variable*
| > here, that happens to have a *specific meaning* for shells.
| It may help to state the *specific meaning* of ENV in POSIX shells. I
| looked at the man page for bash and it says:
|   "When invoked as an interactive shell with the name sh, bash looks
| for the variable ENV, expands its value  if  it  is defined,  and uses
| the expanded value as the name of a file to read and execute."


| So I can imagine a call to "$ENV sh something" in a makefile to
| explode. What actually happened?

First of, my shell is Zsh, not bash -- but I'm running on a Linux box
so "sh" really is "bash".

Now, the story.  Make needs a shell.  The widely recommended practice
is to use sh.  More specifically, every Makefile shall have this line

    SHELL = /bin/sh

at the very start (unless you're using GNU make, in this case it is
built-in).  You're not obliged to use sh -- for example, sh on SunOS
sucks; you have to use something else, bash or ksh.

There is this line in the Makefile for regression testing:

          ${ENV} ${MAKE} DAASE=$(axiom_targetdir) regression-tests

Notice that there is no explicit mention of sh, but Make will call it
because that is the way Make works.

In my case, I stepped into the build directory for input/ and typed
make.  At that point ENV (which is exported by my login shell) has the
value dictated by POSIX, but not overriden by toplevel Makefile.  So
it expanded to /etc/bash.bashrc.

Notice that even if ENV has been overriden by the toplevel Makefile,
that doing is still wrong (it is only a matter of time to trip over
it) because the shell will see that the variable is defined and
attempt to use its value as indicating a file to read and execute.

-- Gaby

reply via email to

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