Improve binary search algorithm

If a directory of the same name is in the current directory, this preventing the search running.  So, if the binary path is not fully qualified always search, and check to ensure it is a file that is found, rather than an executable directory.
Thanks to Ian Marsh for the patch
This commit is contained in:
Duncan Ferguson 2009-11-27 19:11:17 +00:00
parent 214f5a6a71
commit 77e31c4a62
3 changed files with 7 additions and 2 deletions

View file

@ -6,6 +6,10 @@
- Thanks to anonymous for the patch
* Allow for long line continuation in config files with a backslash
- Thanks to Mike Loseke for the patch
* Improve binary search to
- ignore directories of the same name, and
- always search for the binary if it is not fully qualified
- Thanks to Ian Marsh for the patch
2009-09-24 Duncan Ferguson <duncan_ferguson@user.sf.net> - v3.27

1
THANKS
View file

@ -32,5 +32,6 @@ Stanislas Rouvelin
Sami Kerola
Kristian Lyngstol
Mike Loseke
Ian Marsh
$Id$

View file

@ -307,7 +307,7 @@ sub find_binary($) {
logmsg( 2, "Looking for $binary" );
my $path;
if ( !-x $binary ) {
if ( !-x $binary || substr($binary, 0, 1) ne '/' ) {
# search the users $PATH and then a few other places to find the binary
# just in case $PATH isnt set up right
@ -326,7 +326,7 @@ sub find_binary($) {
{
logmsg( 3, "Looking in $_" );
if ( -x $_ . '/' . $binary ) {
if ( -f $_ . '/' . $binary && -x $_ . '/' . $binary ) {
$path = $_ . '/' . $binary;
logmsg( 2, "Found at $path" );
last;