mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-29 08:09:02 +00:00
c7b469f0f3
backward-incompatible change in the 2008 POSIX specification. - Add the .SHELLFLAGS variable so people can choose their own shell flags. - Add tests for this. - Add documentation for this.
73 lines
2 KiB
Perl
73 lines
2 KiB
Perl
# -*-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?
|
|
resetENV();
|
|
delete $ENV{SHELL};
|
|
$mshell = `echo 'all:;\@echo \$(SHELL)' | $make_path -f-`;
|
|
chop $mshell;
|
|
|
|
# According to POSIX, the value of SHELL in the environment has no impact on
|
|
# the value in the makefile.
|
|
# Note %extraENV takes precedence over the default value for the shell.
|
|
|
|
$extraENV{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 /./ which
|
|
# works well on UNIX and seems to work OK on at least some non-UNIX systems.
|
|
|
|
$extraENV{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.
|
|
|
|
$extraENV{SHELL} = $mshell;
|
|
|
|
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.
|
|
|
|
$extraENV{SHELL} = $mshell;
|
|
|
|
run_make_test("all: SHELL := /./$mshell\n".'
|
|
all:;@echo "$(SHELL) $$SHELL"
|
|
', '', "/./$mshell $mshell");
|
|
|
|
$extraENV{SHELL} = $mshell;
|
|
|
|
run_make_test("
|
|
SHELL := /././$mshell
|
|
one: two
|
|
two: export SHELL := /./$mshell\n".'
|
|
one two:;@echo "$@: $(SHELL) $$SHELL"
|
|
', '', "two: /./$mshell /./$mshell\none: /././$mshell $mshell\n");
|
|
|
|
# Test .SHELLFLAGS
|
|
|
|
run_make_test(q!
|
|
.SHELLFLAGS = -xc
|
|
all: ; @true
|
|
!,
|
|
'', "+ true\n");
|
|
|
|
run_make_test(q!
|
|
.SHELLFLAGS = -xec
|
|
all: ; @true; false; true
|
|
!,
|
|
'', "+ true\n+ false\n#MAKE#: *** [all] Error 1\n", 512);
|
|
|
|
1;
|