]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: fixup `checkcmd` `PATH` on non-unixy platforms
authorViktor Szakats <commit@vsz.me>
Tue, 1 Oct 2024 10:25:21 +0000 (12:25 +0200)
committerViktor Szakats <commit@vsz.me>
Tue, 1 Oct 2024 14:05:13 +0000 (16:05 +0200)
Do not add unixy system directories to `PATH` when looking up commands
on Windows, MS-DOS or OS/2.

Cherry-picked from #14949
Closes #15106

tests/servers.pm

index c07097dca300da6061e6151c1be862249fb58a4f..216ec74be88a13078ee26f4b12a731d8f4a3ad2d 100644 (file)
@@ -155,13 +155,15 @@ our $stunnel;        # path to stunnel command
 #
 sub checkcmd {
     my ($cmd, @extrapaths)=@_;
-    my $sep = '[:]';
+    my @paths;
     if ($^O eq 'MSWin32' || $^O eq 'dos' || $^O eq 'os2') {
         # PATH separator is different
-        $sep = '[;]';
+        @paths=(split(';', $ENV{'PATH'}), @extrapaths);
+    }
+    else {
+        @paths=(split(':', $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
+                "/sbin", "/usr/bin", "/usr/local/bin", @extrapaths);
     }
-    my @paths=(split(m/$sep/, $ENV{'PATH'}), "/usr/sbin", "/usr/local/sbin",
-               "/sbin", "/usr/bin", "/usr/local/bin", @extrapaths);
     for(@paths) {
         if( -x "$_/$cmd" . exe_ext('SYS') && ! -d "$_/$cmd" . exe_ext('SYS')) {
             # executable bit but not a directory!