summaryrefslogtreecommitdiff
path: root/tests/scripts/variables/SHELL
blob: 93c18723a87ebd8cb9f5cd322e024919b922efaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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_path -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;