diff options
author | Paul Smith <psmith@gnu.org> | 2004-11-28 23:11:23 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2004-11-28 23:11:23 +0000 |
commit | 539f513773b2e651d987a7bdbdffd8b5164d58cf (patch) | |
tree | 7a692764273cc0892dbc715b6e095f63f93ea1e8 /tests | |
parent | d27cac1598207e9bfc3ffb47c7e609360b83ca69 (diff) | |
download | gunmake-539f513773b2e651d987a7bdbdffd8b5164d58cf.tar.gz |
Fix for bug #1276: Handle SHELL according to POSIX requirements.
POSIX requires that the value of SHELL in the makefile NOT be exported
to sub-commands. Instead, the value in the environment when make was
invoked should be passed to the environment of sub-commands. Note that
make still uses SHELL to _run_ sub-commands; it just doesn't change the
value of the SHELL variable in the environment of sub-commands.
As an extension to POSIX, if the makefile explicitly exports SHELL then
GNU make _will_ use it in the environment of sub-commands.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 5 | ||||
-rw-r--r-- | tests/scripts/variables/MAKELEVEL | 3 | ||||
-rw-r--r-- | tests/scripts/variables/SHELL | 49 |
3 files changed, 55 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 8cc25db..a6423b0 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2004-11-28 Paul D. Smith <psmith@gnu.org> + + * scripts/variables/SHELL: New file: test proper handling of SHELL + according to POSIX rules. Fixes bug #1276. + 2004-10-21 Boris Kolpackov <boris@kolpackov.net> * scripts/functions/word: Test $(firstword ) and $(lastword ). diff --git a/tests/scripts/variables/MAKELEVEL b/tests/scripts/variables/MAKELEVEL index 79a184e..96a4e74 100644 --- a/tests/scripts/variables/MAKELEVEL +++ b/tests/scripts/variables/MAKELEVEL @@ -1,4 +1,4 @@ -# -*-perl-mode-*- +# -*-perl-*- $description = "The following test creates a makefile to test makelevels in Make. It prints \$(MAKELEVEL) and then @@ -9,7 +9,6 @@ open(MAKEFILE,"> $makefile"); # The Contents of the MAKEFILE ... print MAKEFILE <<EOF; -SHELL = /bin/sh all: \t\@echo MAKELEVEL is \$(MAKELEVEL) \techo \$\$MAKELEVEL diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL new file mode 100644 index 0000000..9ff5c4b --- /dev/null +++ b/tests/scripts/variables/SHELL @@ -0,0 +1,49 @@ +# -*-perl-*- + +$description = "Test proper handling of SHELL."; + +# Find the default value when SHELL is not set. On UNIX it will be /bin/sh, +# but on other platforms who knows? +$oshell = $ENV{SHELL}; +delete $ENV{SHELL}; +$mshell = `echo 'all:;\@echo \$(SHELL)' | $make_name -f-`; +chop $mshell; + +# According to POSIX, the value of SHELL in the environment has no impact on +# the value in the makefile. + +$ENV{SHELL} = '/dev/null'; +run_make_test('all:;@echo "$(SHELL)"', '', $mshell); + +# According to POSIX, any value of SHELL set in the makefile should _NOT_ be +# exported to the subshell! I wanted to set SHELL to be $^X (perl) in the +# makefile, but make runs $(SHELL) -c 'commandline' and that doesn't work at +# all when $(SHELL) is perl :-/. So, we just add an extra initial / and hope +# for the best on non-UNIX platforms :-/. + +$ENV{SHELL} = $mshell; + +run_make_test("SHELL := /$mshell\n".' +all:;@echo "$(SHELL) $$SHELL" +', '', "/$mshell $mshell"); + +# As a GNU make extension, if make's SHELL variable is explicitly exported, +# then we really _DO_ export it. + +run_make_test("export SHELL := /$mshell\n".' +all:;@echo "$(SHELL) $$SHELL" +', '', "/$mshell /$mshell"); + + +# Test out setting of SHELL, both exported and not, as a target-specific +# variable. + +run_make_test("all: SHELL := /$mshell\n".' +all:;@echo "$(SHELL) $$SHELL" +', '', "/$mshell $mshell"); + +run_make_test("all: export SHELL := /$mshell\n".' +all:;@echo "$(SHELL) $$SHELL" +', '', "/$mshell $mshell"); + +1; |