Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ExtUtils/MM_Unix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2896,6 +2896,8 @@ Returns true, if the argument is likely to be a command.

sub maybe_command {
my($self,$file) = @_;
# $file = '' if (!defined $file or !length $file);
return unless defined $file and length $file;
return $file if -x $file && ! -d $file;
return;
}
Expand Down
28 changes: 26 additions & 2 deletions t/MM_Unix.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BEGIN {
plan skip_all => 'Non-Unix platform';
}
else {
plan tests => 114;
plan tests => 118;
}
}

Expand Down Expand Up @@ -178,7 +178,31 @@ is ($t->libscan('Fatty'), 'Fatty', 'libscan on something not a VC file' );

open(FILE, ">command"); print FILE "foo"; close FILE;
SKIP: {
skip("no separate execute mode on VOS", 2) if $^O eq "vos";
skip("no separate execute mode on VOS", 4) if $^O eq "vos";

{
local $@;
my $rv;
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
eval { $rv = $t->maybe_command( undef ); };
ok (! @warnings, "maybe_command emits no warnings with undefined argument");
ok (! defined $rv,
"maybe_command returns undef if not provided defined argument"
);
}

{
local $@;
my $rv;
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
eval { $rv = $t->maybe_command( '' ); };
ok (! @warnings, "maybe_command emits no warnings with empty-string argument");
ok (! defined $rv,
"maybe_command returns undef if not provided positive-length argument"
);
}

ok !$t->maybe_command('command') ,"non executable file isn't a command";

Expand Down