Skip to content

Commit

Permalink
Fix checking command existence
Browse files Browse the repository at this point in the history
  • Loading branch information
ferki committed Aug 3, 2023
1 parent 84ff1ce commit a217158
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Expand Up @@ -4,6 +4,7 @@ Revision history for Rex
[API CHANGES]

[BUG FIXES]
- Fix checking command existence

[DOCUMENTATION]

Expand Down
10 changes: 6 additions & 4 deletions lib/Rex/Interface/Exec/Base.pm
Expand Up @@ -8,6 +8,7 @@ use v5.12.5;
use warnings;
use Carp;
use Rex::Helper::Run;
use Rex::Commands::Fs;

our $VERSION = '9999.99.99_99'; # VERSION

Expand Down Expand Up @@ -64,15 +65,16 @@ sub can_run {
return $cache->get($cache_key_name);
}

my @output = Rex::Helper::Run::i_run "$check_with_command $command",
my $output = Rex::Helper::Run::i_run "$check_with_command $command",
fail_ok => 1;

next if ( $? != 0 );
next if ( grep { /^no $command in/ } @output ); # for solaris

$cache->set( $cache_key_name, $output[0] );
next if ( !is_file($output) );

return $output[0];
$cache->set( $cache_key_name, $output );

return $output;
}

return undef;
Expand Down

0 comments on commit a217158

Please sign in to comment.