2004-11-28 23:11:23 +00:00
|
|
|
# -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test proper handling of SHELL.";
|
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
# If we don't have a POSIX shell available, never mind
|
|
|
|
$is_posix_sh or return -1;
|
|
|
|
|
2018-07-01 20:13:13 +00:00
|
|
|
# On Windows, shell names might not match
|
|
|
|
if ($port_type eq 'W32') {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
$mshell = $sh_name;
|
2004-11-28 23:11:23 +00:00
|
|
|
|
|
|
|
# According to POSIX, the value of SHELL in the environment has no impact on
|
|
|
|
# the value in the makefile.
|
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{SHELL} = '/dev/null';
|
2004-11-28 23:11:23 +00:00
|
|
|
run_make_test('all:;@echo "$(SHELL)"', '', $mshell);
|
|
|
|
|
2020-11-28 17:30:08 +00:00
|
|
|
# According to POSIX, any value of SHELL set in the makefile should not be
|
|
|
|
# exported to the subshell. A more portable option might be to set SHELL to
|
|
|
|
# be $^X (perl) in the makefile, and set .SHELLFLAGS to -e.
|
2004-11-28 23:11:23 +00:00
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{SHELL} = $mshell;
|
2004-11-28 23:11:23 +00:00
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
my $altshell = "/./$mshell";
|
|
|
|
my $altshell2 = "/././$mshell";
|
2020-11-28 17:30:08 +00:00
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
if ($mshell =~ m,^([a-zA-Z]:)([\\/])(.*),) {
|
|
|
|
$altshell = "$1$2.$2$3";
|
|
|
|
$altshell2 = "$1$2.$2.$2$3";
|
|
|
|
}
|
|
|
|
|
|
|
|
run_make_test("SHELL := $altshell\n".'
|
2004-11-28 23:11:23 +00:00
|
|
|
all:;@echo "$(SHELL) $$SHELL"
|
2017-04-17 19:37:57 +00:00
|
|
|
', '', "$altshell $mshell");
|
2004-11-28 23:11:23 +00:00
|
|
|
|
|
|
|
# As a GNU make extension, if make's SHELL variable is explicitly exported,
|
|
|
|
# then we really _DO_ export it.
|
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{SHELL} = $mshell;
|
2005-07-12 04:35:13 +00:00
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
run_make_test("export SHELL := $altshell\n".'
|
2004-11-28 23:11:23 +00:00
|
|
|
all:;@echo "$(SHELL) $$SHELL"
|
2017-04-17 19:37:57 +00:00
|
|
|
', '', "$altshell $altshell");
|
2004-11-28 23:11:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Test out setting of SHELL, both exported and not, as a target-specific
|
|
|
|
# variable.
|
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{SHELL} = $mshell;
|
2005-07-12 04:35:13 +00:00
|
|
|
|
2017-04-17 19:37:57 +00:00
|
|
|
run_make_test("all: SHELL := $altshell\n".'
|
2004-11-28 23:11:23 +00:00
|
|
|
all:;@echo "$(SHELL) $$SHELL"
|
2017-04-17 19:37:57 +00:00
|
|
|
', '', "$altshell $mshell");
|
2004-11-28 23:11:23 +00:00
|
|
|
|
2020-04-01 05:58:33 +00:00
|
|
|
$ENV{SHELL} = $mshell;
|
2005-07-12 04:35:13 +00:00
|
|
|
|
2009-06-06 23:16:46 +00:00
|
|
|
run_make_test("
|
2017-04-17 19:37:57 +00:00
|
|
|
SHELL := $altshell2
|
2009-06-06 23:16:46 +00:00
|
|
|
one: two
|
2017-04-17 19:37:57 +00:00
|
|
|
two: export SHELL := $altshell\n".'
|
2009-06-06 23:16:46 +00:00
|
|
|
one two:;@echo "$@: $(SHELL) $$SHELL"
|
2017-04-17 19:37:57 +00:00
|
|
|
', '', "two: $altshell $altshell\none: $altshell2 $mshell\n");
|
2004-11-28 23:11:23 +00:00
|
|
|
|
2010-07-06 06:37:42 +00:00
|
|
|
# Test .SHELLFLAGS
|
|
|
|
|
2010-07-28 05:39:50 +00:00
|
|
|
# We don't know the output here: on Solaris for example, every line printed
|
2010-07-19 07:10:53 +00:00
|
|
|
# by the shell in -x mode has a trailing space (!!)
|
2010-07-28 05:39:50 +00:00
|
|
|
my $script = 'true; true';
|
|
|
|
my $flags = '-xc';
|
2017-04-17 19:37:57 +00:00
|
|
|
my $out = `$sh_name $flags '$script' 2>&1`;
|
2010-07-19 07:10:53 +00:00
|
|
|
|
2012-03-03 22:56:20 +00:00
|
|
|
run_make_test(qq!
|
|
|
|
.SHELLFLAGS = $flags
|
|
|
|
all: ; \@$script
|
|
|
|
!,
|
|
|
|
'', $out);
|
|
|
|
|
|
|
|
# Do it again but add spaces to SHELLFLAGS
|
2013-09-29 17:31:32 +00:00
|
|
|
|
|
|
|
# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
|
|
|
|
# separate arguments.
|
2017-04-17 19:37:57 +00:00
|
|
|
my $t = `$sh_name -e -c true 2>/dev/null`;
|
2013-09-29 17:31:32 +00:00
|
|
|
my $multi_ok = $? == 0;
|
|
|
|
|
|
|
|
if ($multi_ok) {
|
|
|
|
$flags = '-x -c';
|
|
|
|
run_make_test(qq!
|
2010-07-28 05:39:50 +00:00
|
|
|
.SHELLFLAGS = $flags
|
2010-07-19 07:10:53 +00:00
|
|
|
all: ; \@$script
|
2010-07-06 06:37:42 +00:00
|
|
|
!,
|
2010-07-19 07:10:53 +00:00
|
|
|
'', $out);
|
2013-09-29 17:31:32 +00:00
|
|
|
}
|
2010-07-19 07:10:53 +00:00
|
|
|
|
|
|
|
# We can't just use "false" because on different systems it provides a
|
2010-07-28 05:39:50 +00:00
|
|
|
# different exit code--once again Solaris: false exits with 255 not 1
|
|
|
|
$script = 'true; false; true';
|
|
|
|
$flags = '-xec';
|
2017-04-17 19:37:57 +00:00
|
|
|
$out = `$sh_name $flags '$script' 2>&1`;
|
2010-07-28 05:39:50 +00:00
|
|
|
my $err = $? >> 8;
|
2010-07-06 06:37:42 +00:00
|
|
|
|
2010-07-19 07:10:53 +00:00
|
|
|
run_make_test(qq!
|
2010-07-28 05:39:50 +00:00
|
|
|
.SHELLFLAGS = $flags
|
2010-07-19 07:10:53 +00:00
|
|
|
all: ; \@$script
|
2010-07-06 06:37:42 +00:00
|
|
|
!,
|
2019-09-22 21:02:57 +00:00
|
|
|
'', "$out#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);
|
2010-07-06 06:37:42 +00:00
|
|
|
|
2004-11-28 23:11:23 +00:00
|
|
|
1;
|