xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/variables/SHELL (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "Test proper handling of SHELL.";
4*69606e3fSchristos
5*69606e3fSchristos# Find the default value when SHELL is not set.  On UNIX it will be /bin/sh,
6*69606e3fSchristos# but on other platforms who knows?
7*69606e3fSchristosresetENV();
8*69606e3fSchristosdelete $ENV{SHELL};
9*69606e3fSchristos$mshell = `echo 'all:;\@echo \$(SHELL)' | $make_path -f-`;
10*69606e3fSchristoschop $mshell;
11*69606e3fSchristos
12*69606e3fSchristos# According to POSIX, the value of SHELL in the environment has no impact on
13*69606e3fSchristos# the value in the makefile.
14*69606e3fSchristos# Note %extraENV takes precedence over the default value for the shell.
15*69606e3fSchristos
16*69606e3fSchristos$extraENV{SHELL} = '/dev/null';
17*69606e3fSchristosrun_make_test('all:;@echo "$(SHELL)"', '', $mshell);
18*69606e3fSchristos
19*69606e3fSchristos# According to POSIX, any value of SHELL set in the makefile should _NOT_ be
20*69606e3fSchristos# exported to the subshell!  I wanted to set SHELL to be $^X (perl) in the
21*69606e3fSchristos# makefile, but make runs $(SHELL) -c 'commandline' and that doesn't work at
22*69606e3fSchristos# all when $(SHELL) is perl :-/.  So, we just add an extra initial /./ which
23*69606e3fSchristos# works well on UNIX and seems to work OK on at least some non-UNIX systems.
24*69606e3fSchristos
25*69606e3fSchristos$extraENV{SHELL} = $mshell;
26*69606e3fSchristos
27*69606e3fSchristosrun_make_test("SHELL := /./$mshell\n".'
28*69606e3fSchristosall:;@echo "$(SHELL) $$SHELL"
29*69606e3fSchristos', '', "/./$mshell $mshell");
30*69606e3fSchristos
31*69606e3fSchristos# As a GNU make extension, if make's SHELL variable is explicitly exported,
32*69606e3fSchristos# then we really _DO_ export it.
33*69606e3fSchristos
34*69606e3fSchristos$extraENV{SHELL} = $mshell;
35*69606e3fSchristos
36*69606e3fSchristosrun_make_test("export SHELL := /./$mshell\n".'
37*69606e3fSchristosall:;@echo "$(SHELL) $$SHELL"
38*69606e3fSchristos', '', "/./$mshell /./$mshell");
39*69606e3fSchristos
40*69606e3fSchristos
41*69606e3fSchristos# Test out setting of SHELL, both exported and not, as a target-specific
42*69606e3fSchristos# variable.
43*69606e3fSchristos
44*69606e3fSchristos$extraENV{SHELL} = $mshell;
45*69606e3fSchristos
46*69606e3fSchristosrun_make_test("all: SHELL := /./$mshell\n".'
47*69606e3fSchristosall:;@echo "$(SHELL) $$SHELL"
48*69606e3fSchristos', '', "/./$mshell $mshell");
49*69606e3fSchristos
50*69606e3fSchristos$extraENV{SHELL} = $mshell;
51*69606e3fSchristos
52*69606e3fSchristosrun_make_test("all: export SHELL := /./$mshell\n".'
53*69606e3fSchristosall:;@echo "$(SHELL) $$SHELL"
54*69606e3fSchristos', '', "/./$mshell $mshell");
55*69606e3fSchristos
56*69606e3fSchristos1;
57