Skip to content

Commit

Permalink
tests: fixup checkcmd PATH on non-unixy platforms
Browse files Browse the repository at this point in the history
Do not add unixy system directories to `PATH` when looking up commands
on Windows, MS-DOS or OS/2.

Cherry-picked from curl#14949
Closes curl#15106
  • Loading branch information
vszakats committed Oct 1, 2024
1 parent f88fb1c commit aa09201
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/servers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit aa09201

Please sign in to comment.