[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd effects from setting SHELL?
From: |
Bob Proulx |
Subject: |
Re: Odd effects from setting SHELL? |
Date: |
Tue, 3 Jul 2007 00:40:05 -0600 |
User-agent: |
Mutt/1.5.9i |
Philip Guenther wrote:
> As an extension, some versions of bash treat ">&word" as ">word 2>&1"
> if 'word' doesn't expand to one or more digits or to just a hyphen.
> Check your system's manpage and experiment a bit...
Good catch. That is very likely something that is adding confusion.
> Make will use /bin/sh by default when invoking commands, but by
> default it does *not* override the value of SHELL in the environment
> of the commands.
Actually it does depending upon which version of GNU make we are
talking about. Older versions such as 3.80 *did* override the
environment version of SHELL. Newer versions such as 3.81 now do not.
What you are saying is definitely true of the newer version but the
older version did it the other way and it is still quite commonly seen
in the wild.
In the NEWS file for GNU make 3.81:
* Changes made for POSIX compatibility:
- Setting the SHELL make variable does NOT change the value of the
SHELL environment variable given to programs invoked by make. As
an enhancement to POSIX, if you export the make variable SHELL then
it will be set in the environment, just as before.
> Indeed, if you don't explicitly set SHELL in the makefile, then
> ${SHELL} will expand to the shell of the user invoking make. So,
> any rules that explicitly use ${SHELL} or that invoke commands that
> use SHELL internally may behave differently for different users.
The Makefile $(SHELL) will still get set to /bin/sh by default unless
overridden in the Makefile regardless of the invoking environment but
the environment passed to commands will be the SHELL from the
environment that invoked make. Whew!
Here is a Makefile to test this question:
all:
echo $(SHELL)
echo $$SHELL
printenv SHELL
$ make --version
GNU Make 3.81
$ SHELL=/bin/bash make
echo /bin/sh
/bin/sh
echo $SHELL
/bin/bash
printenv SHELL
/bin/bash
$ SHELL=/bin/csh make
echo /bin/sh
/bin/sh
echo $SHELL
/bin/csh
printenv SHELL
/bin/csh
$ make SHELL=/bin/csh
echo /bin/csh
/bin/csh
echo $SHELL
/bin/bash
printenv SHELL
/bin/bash
It really is "You can't tell the players without a scorecard."
Bob
- Re: Odd effects from setting SHELL?,
Bob Proulx <=