]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* tests/*: Quote backticked command paths
authorPaul Smith <psmith@gnu.org>
Tue, 26 Aug 2025 12:53:00 +0000 (08:53 -0400)
committerPaul Smith <psmith@gnu.org>
Wed, 27 Aug 2025 02:54:34 +0000 (22:54 -0400)
When using Perl's backticks make sure that the path to the command
invoked is quoted.  On Windows, in particular, paths to commands such
as diff, etc. may contain whitespace.

tests/run_make_tests.pl
tests/scripts/features/archives
tests/scripts/features/load
tests/scripts/features/loadapi
tests/scripts/functions/realpath
tests/scripts/options/dash-I
tests/scripts/targets/ONESHELL
tests/scripts/targets/POSIX
tests/scripts/variables/INCLUDE_DIRS
tests/scripts/variables/SHELL
tests/test_driver.pl

index 4296e30285fefeff4d3e04b0c3e77db8deb34f91..c96422c8354ac6d3faad39bbd62b3bf6721ddb24 100644 (file)
@@ -530,7 +530,7 @@ sub set_more_defaults
     $make_path = 'make';
   } else {
     create_file('make.mk', 'all:;$(info $(MAKE))');
-    my $mk = `$make_path -sf make.mk`;
+    my $mk = `"$make_path" -sf make.mk`;
     unlink('make.mk');
     $mk =~ s/\r?\n$//;
     $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
@@ -540,18 +540,18 @@ sub set_more_defaults
 
   # Ask make what shell to use
   create_file('shell.mk', 'all:;$(info $(SHELL))');
-  $sh_name = `$make_path -sf shell.mk`;
+  $sh_name = `"$make_path" -sf shell.mk`;
   unlink('shell.mk');
   $sh_name =~ s/\r?\n$//;
   if (! $sh_name) {
       print "Cannot determine shell\n";
       $is_posix_sh = 0;
   } else {
-      my $o = `$sh_name -c ': do nothing' 2>&1`;
+      my $o = `"$sh_name" -c ': do nothing' 2>&1`;
       $is_posix_sh = $? == 0 && $o eq '';
   }
 
-  $string = `$make_path -v`;
+  $string = `"$make_path" -v`;
   $string =~ /^(GNU Make [^,\n]*)/ or die "$make_path is not GNU Make.  Version:\n$string";
   $testee_version = "$1\n";
 
@@ -559,7 +559,7 @@ sub set_more_defaults
 
   my $redir = '2>&1';
   $redir = '' if os_name eq 'VMS';
-  $string = `$make_path -f null.mk $redir`;
+  $string = `"$make_path" -f null.mk $redir`;
   if ($string =~ /(.*): \*\*\* No targets\.  Stop\./) {
     $make_name = $1;
   } else {
@@ -593,7 +593,7 @@ sub set_more_defaults
     $purify_errors = 0;
   }
 
-  $string = `$make_path -j 2 -f null.mk $redir`;
+  $string = `"$make_path" -j 2 -f null.mk $redir`;
   if ($string =~ /not supported/) {
     $parallel_jobs = 0;
   }
@@ -604,7 +604,7 @@ sub set_more_defaults
   unlink('null.mk');
 
   create_file('features.mk', 'all:;$(info $(.FEATURES))');
-  %FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`;
+  %FEATURES = map { $_ => 1 } split /\s+/, `"$make_path" -sf features.mk`;
   print "$make_path FEATURES: @{[%FEATURES]}\n" if $verbose;
   unlink('features.mk');
 
@@ -614,7 +614,7 @@ sub set_more_defaults
       $s .= "\$(info $_=\$($_))\n";
   }
   create_file('defvars.mk', $s);
-  foreach (split "\n", `$make_path -sf defvars.mk`) {
+  foreach (split "\n", `"$make_path" -sf defvars.mk`) {
       my @e = split /=/, $_, 2;
       $DEFVARS{$e[0]} = $e[1];
   }
index 81f515e3003f3ed468d6e5c86f079a605151be74..2c4932a525cf69fb5caec4bac4701cab687b402f 100644 (file)
@@ -41,7 +41,7 @@ my $arvar = "AR=\"$ar\"";
 # which forces all timestamps (among other things) to always be 0, defeating
 # GNU Make's archive support.  See if ar supports the U option to disable it.
 unlink('libxx.a');
-$_ = `$ar ${arflags}U libxx.a a1.o $redir`;
+$_ = `"$ar" ${arflags}U libxx.a a1.o $redir`;
 if ($? == 0) {
     $arflags = "${arflags}U";
     $arvar = "$arvar ARFLAGS=\"$arflags\"";
@@ -49,15 +49,15 @@ if ($? == 0) {
 
 # Some versions of ar print different things on creation.  Find out.
 unlink('libxx.a');
-my $created = `$ar $arflags libxx.a a1.o $redir`;
+my $created = `"$ar" $arflags libxx.a a1.o $redir`;
 $created =~ s/a1\.o/#OBJECT#/g;
 
 # Some versions of ar print different things on add.  Find out.
-my $add = `$ar $arflags libxx.a a2.o $redir`;
+my $add = `"$ar" $arflags libxx.a a2.o $redir`;
 $add =~ s/a2\.o/#OBJECT#/g;
 
 # Some versions of ar print different things on replacement.  Find out.
-my $repl = `$ar $arflags libxx.a a2.o $redir`;
+my $repl = `"$ar" $arflags libxx.a a2.o $redir`;
 $repl =~ s/a2\.o/#OBJECT#/g;
 
 unlink('libxx.a');
@@ -244,9 +244,9 @@ if ($osname ne 'os390') {
 # Find the output when creating an archive from multiple files
 
 utouch(-10, 'a.o', 'b.o');
-my $create2 = `$ar $arflags mylib.a a.o b.o $redir`;
+my $create2 = `"$ar" $arflags mylib.a a.o b.o $redir`;
 touch('b.o');
-my $add2 = `$ar $arflags mylib.a b.o $redir`;
+my $add2 = `"$ar" $arflags mylib.a b.o $redir`;
 unlink('a.o', 'b.o', 'mylib.a');
 
 # Some systems complain when compiling empty files
index 6967a5bd5edb5b757a8692818e78168ecd715d9c..be2670e4cf7d03a2dba845d45db9b049063618ee 100644 (file)
@@ -57,7 +57,7 @@ close($F) or die "close: testload.c: $!\n";
 my $cppflags = get_config('CPPFLAGS') . ($srcdir ? " -I$srcdir/src" : '');
 my $cflags = get_config('CFLAGS') . ' -fPIC';
 my $ldflags = get_config('LDFLAGS') . ' -shared';
-my $sobuild = "$cc $cppflags $cflags $ldflags -o testload.so testload.c";
+my $sobuild = "\"$cc\" $cppflags $cflags $ldflags -o testload.so testload.c";
 
 my $clog = `$sobuild 2>&1`;
 if ($? != 0) {
index ab8ca23b5ae6c5c4b6e200dd70445c93b935b055..e2f23d1b6269b0c196565365db0136270ae2a678 100644 (file)
@@ -131,7 +131,7 @@ close($F) or die "close: testapi.c: $!\n";
 my $cflags = get_config('CFLAGS');
 my $cppflags = get_config('CPPFLAGS');
 my $ldflags = get_config('LDFLAGS');
-my $sobuild = "$cc ".($srcdir? "-I$srcdir/src":'')." $cppflags $cflags -shared -fPIC $ldflags -o testapi.so testapi.c";
+my $sobuild = "\"$cc\" ".($srcdir? "-I$srcdir/src":'')." $cppflags $cflags -shared -fPIC $ldflags -o testapi.so testapi.c";
 
 my $clog = `$sobuild 2>&1`;
 if ($? != 0) {
index 492db598aabd58ab1c1a13ef2bfdeda066bb2784..19af19f9f6e5624d2c03f36c57f92eb1d4649f86 100644 (file)
@@ -24,7 +24,7 @@ all: ; @:
 
 # Find the realpath to the root of the partition
 create_file('root.mk', 'all:;$(info $(realpath /))');
-my $root = `$make_path -sf root.mk`;
+my $root = `"$make_path" -sf root.mk`;
 unlink('root.mk');
 $root =~ s/\r?\n//g;
 
index 37178b3d5b07fcd49c80ccac067a6d0d16ad1e6a..764deea161ed1a26712aaabcae01fca48bd09fbb 100644 (file)
@@ -83,7 +83,7 @@ rmdir('idir2');
 # won't work if none of the default directories contain any files :-/
 
 create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n");
-my $cmd = subst_make_string("#MAKEPATH# -f defaultdirs.mk");
+my $cmd = subst_make_string('"#MAKEPATH#" -f defaultdirs.mk');
 my @dirs = `$cmd`;
 my $dirs = $dirs[0];
 $dirs =~ s/\r?\n//g;
index 1ea6e178837a13d0879b0c8b721a7085f4022ddc..3e38f92e875a8b0857b59ef4d70ad877c8c0dc8e 100644 (file)
@@ -9,7 +9,7 @@ my $multi_ok = 0;
 if ($port_type ne 'W32') {
     # Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
     # separate arguments.
-    my $t = `$sh_name -e -c true 2>/dev/null`;
+    my $t = `"$sh_name" -e -c true 2>/dev/null`;
     $multi_ok = $? == 0;
 }
 
index 43e1cf91d255a96b1548a648c4709b9e3543c0ea..b5137c086fb2fef332f513f354f18e8bd0b6c6b0 100644 (file)
@@ -82,7 +82,7 @@ all: .SHELLFLAGS = -ec
 # Different versions of sh generate different output for -x so check it
 my $script = subst_make_string('#HELPER# -q fail 1; true');
 my $flags = '-xc';
-my $out = `$sh_name $flags '$script' 2>&1`;
+my $out = `"$sh_name" $flags '$script' 2>&1`;
 
 run_make_test(qq!
 .SHELLFLAGS = $flags
index 353630df0401b1130cbb6ea6461f04d055e31c09..93ff0c1f6ea64ff08b9417ab4b8716617bd543c1 100644 (file)
@@ -42,7 +42,7 @@ all:;@:
 
 # Find the default .INCLUDE_DIRS
 create_file('defaultdirs.mk', "\$(info \$(.INCLUDE_DIRS))\nall:;\@:\n");
-my $cmd = subst_make_string("#MAKEPATH# -f defaultdirs.mk");
+my $cmd = subst_make_string('"#MAKEPATH#" -f defaultdirs.mk');
 my @dirs = `$cmd`;
 my $dirs = $dirs[0];
 $dirs =~ s/\r?\n//g;
index b18754fa70b52fe1c20b85a925521a6c704ff607..7b5faa68b0f318385ebd0ead0df11302f8a693c4 100644 (file)
@@ -70,7 +70,7 @@ one two:;@echo "$@: $(SHELL) $$SHELL"
 # printed by the shell in -x mode has a trailing space!
 my $script = 'true; true';
 my $flags = '-xc';
-my $out = `$sh_name $flags '$script' 2>&1`;
+my $out = `"$sh_name" $flags '$script' 2>&1`;
 
 run_make_test(qq!
 .SHELLFLAGS = $flags
@@ -82,7 +82,7 @@ all: ; \@$script
 
 # Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
 # separate arguments.
-my $t = `$sh_name -e -c true 2>/dev/null`;
+my $t = `"$sh_name" -e -c true 2>/dev/null`;
 my $multi_ok = $? == 0;
 
 if ($multi_ok) {
@@ -96,7 +96,7 @@ all: ; \@$script
 
 $script = subst_make_string('true; #HELPER# -q fail 1; true');
 $flags = '-xec';
-$out = `$sh_name $flags '$script' 2>&1`;
+$out = `"$sh_name" $flags '$script' 2>&1`;
 
 run_make_test(qq!
 .SHELLFLAGS = $flags
index 9db8ec12685d70f21adc3269069622f482e0a67d..a5211d56db8b9a89c0b7c779dfbd09ac332625a3 100644 (file)
@@ -1051,7 +1051,7 @@ sub compare_output
   if (! $matched) {
     # Create the difference file
     if ($diff_name) {
-        run_command_with_output($diff, "$diff_name -c $base $logfile");
+        run_command_with_output($diff, "\"$diff_name\" -c $base $logfile");
     } else {
         create_file($diff, "Log file $logfile differs from base file $base\n");
     }