Humberto Ortiz Zuazaga <[EMAIL PROTECTED]> 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."

Yes.

| 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:

  regress:
          ${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


_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to