From aa092012bd0fd7f30a3aabfccde02fb0df0b95e4 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 1 Oct 2024 12:25:21 +0200 Subject: [PATCH] tests: fixup `checkcmd` `PATH` on non-unixy platforms 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/servers.pm b/tests/servers.pm index c07097dca3..216ec74be8 100644 --- a/tests/servers.pm +++ b/tests/servers.pm @@ -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! -- 2.47.2