VirtualBox

source: kBuild/vendor/gnumake/current/tests/scripts/variables/SHELL@ 2596

最後變更 在這個檔案從2596是 2596,由 bird 提交於 13 年 前

gnumake/current -> 3.82-cvs.

  • 屬性 svn:eol-style 設為 LF
檔案大小: 2.5 KB
 
1# -*-perl-*-
2
3$description = "Test proper handling of SHELL.";
4
5# Find the default value when SHELL is not set. On UNIX it will be /bin/sh,
6# but on other platforms who knows?
7resetENV();
8delete $ENV{SHELL};
9$mshell = `echo 'all:;\@echo \$(SHELL)' | $make_path -f-`;
10chop $mshell;
11
12# According to POSIX, the value of SHELL in the environment has no impact on
13# the value in the makefile.
14# Note %extraENV takes precedence over the default value for the shell.
15
16$extraENV{SHELL} = '/dev/null';
17run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
18
19# According to POSIX, any value of SHELL set in the makefile should _NOT_ be
20# exported to the subshell! I wanted to set SHELL to be $^X (perl) in the
21# makefile, but make runs $(SHELL) -c 'commandline' and that doesn't work at
22# all when $(SHELL) is perl :-/. So, we just add an extra initial /./ which
23# works well on UNIX and seems to work OK on at least some non-UNIX systems.
24
25$extraENV{SHELL} = $mshell;
26
27run_make_test("SHELL := /./$mshell\n".'
28all:;@echo "$(SHELL) $$SHELL"
29', '', "/./$mshell $mshell");
30
31# As a GNU make extension, if make's SHELL variable is explicitly exported,
32# then we really _DO_ export it.
33
34$extraENV{SHELL} = $mshell;
35
36run_make_test("export SHELL := /./$mshell\n".'
37all:;@echo "$(SHELL) $$SHELL"
38', '', "/./$mshell /./$mshell");
39
40
41# Test out setting of SHELL, both exported and not, as a target-specific
42# variable.
43
44$extraENV{SHELL} = $mshell;
45
46run_make_test("all: SHELL := /./$mshell\n".'
47all:;@echo "$(SHELL) $$SHELL"
48', '', "/./$mshell $mshell");
49
50$extraENV{SHELL} = $mshell;
51
52run_make_test("
53SHELL := /././$mshell
54one: two
55two: export SHELL := /./$mshell\n".'
56one two:;@echo "$@: $(SHELL) $$SHELL"
57', '', "two: /./$mshell /./$mshell\none: /././$mshell $mshell\n");
58
59# Test .SHELLFLAGS
60
61# We don't know the output here: on Solaris for example, every line printed
62# by the shell in -x mode has a trailing space (!!)
63my $script = 'true; true';
64my $flags = '-xc';
65my $out = `/bin/sh $flags '$script' 2>&1`;
66
67run_make_test(qq!
68.SHELLFLAGS = $flags
69all: ; \@$script
70!,
71 '', $out);
72
73# We can't just use "false" because on different systems it provides a
74# different exit code--once again Solaris: false exits with 255 not 1
75$script = 'true; false; true';
76$flags = '-xec';
77$out = `/bin/sh $flags '$script' 2>&1`;
78my $err = $? >> 8;
79
80run_make_test(qq!
81.SHELLFLAGS = $flags
82all: ; \@$script
83!,
84 '', "$out#MAKE#: *** [all] Error $err\n", 512);
85
861;
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette