Move findBinary to Xen::Tools::Common
This commit is contained in:
parent
6b64dcc122
commit
4c3e4abff7
@ -218,3 +218,5 @@ Axel's Break-Backwards-Compatibility Wishlist
|
||||
* Uncouple generating auto start symlinks from `--boot`.
|
||||
|
||||
Maybe add some `--autostart` or such.
|
||||
|
||||
* Maybe replace findBinary with File::Which
|
||||
|
||||
@ -4006,38 +4006,6 @@ sub generatePassword {
|
||||
}
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Find the location of the specified binary on the curent user's PATH.
|
||||
|
||||
Return undef if the named binary isn't found.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub findBinary
|
||||
{
|
||||
my ($bin) = (@_);
|
||||
|
||||
# strip any path which might be present.
|
||||
$bin = $2 if ( $bin =~ /(.*)[\/\\](.*)/ );
|
||||
|
||||
foreach my $entry ( split( /:/, $ENV{ 'PATH' } ) )
|
||||
{
|
||||
|
||||
# guess of location.
|
||||
my $guess = $entry . "/" . $bin;
|
||||
|
||||
# return it if it exists and is executable
|
||||
return $guess if ( -e $guess && -x $guess );
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Unmount any mount-points which are below the given path.
|
||||
|
||||
@ -21,7 +21,8 @@ use vars qw(@EXPORT_OK @EXPORT);
|
||||
use English;
|
||||
|
||||
@EXPORT = qw(readConfigurationFile xenRunning runCommand setupAdminUsers
|
||||
findXenToolstack logprint_with_config logonly_with_config fail_with_config);
|
||||
findXenToolstack findBinary
|
||||
logprint_with_config logonly_with_config fail_with_config);
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
@ -137,6 +138,38 @@ sub xenRunning ($$)
|
||||
return ($running);
|
||||
}
|
||||
|
||||
=head2 findBinary
|
||||
|
||||
=begin doc
|
||||
|
||||
Find the location of the specified binary on the curent user's PATH.
|
||||
|
||||
Return undef if the named binary isn't found.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub findBinary
|
||||
{
|
||||
my ($bin) = (@_);
|
||||
|
||||
# strip any path which might be present.
|
||||
$bin = $2 if ( $bin =~ /(.*)[\/\\](.*)/ );
|
||||
|
||||
foreach my $entry ( split( /:/, $ENV{ 'PATH' } ) )
|
||||
{
|
||||
|
||||
# guess of location.
|
||||
my $guess = $entry . "/" . $bin;
|
||||
|
||||
# return it if it exists and is executable
|
||||
return $guess if ( -e $guess && -x $guess );
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
=head2 findXenToolstack
|
||||
|
||||
=begin doc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user