diff --git a/configure b/configure index 4d02defee4f..4d425a815d4 100755 --- a/configure +++ b/configure @@ -398,15 +398,24 @@ my %specific = 'refpost' => '}', 'comment' => '#') ); +sub might_be_executable { + my $path = shift; + return -x $path && -f $path; # On Windows -x can return true for directories +} + sub which { my $file = shift; for my $p (File::Spec->path()) { next if $p eq '.'; - if (-x "$p/$file") { - return "$p/$file"; - } - elsif ($exeext ne '' && -x "$p/$file$exeext") { - return "$p/$file$exeext"; + my $path = "$p/$file"; + if (might_be_executable($path)) { + return $path; + } + elsif ($exeext ne '') { + $path .= $exeext; + if (might_be_executable($path)) { + return $path; + } } } return undef; @@ -470,7 +479,7 @@ sub git_submodule_prop { or die("git_submodule_prop open failed: $!\nStopped"); my $prop_value = <$fd>; close($fd); - chomp($prop_value); + chomp($prop_value) if (defined($prop_value)); if (!$prop_value) { die("Couldn't get $full_prop_name from .gitmodules\nStopped"); }