From: Seewer Philippe Date: Fri, 27 Feb 2009 13:28:40 +0000 (+0100) Subject: Fix find_binary always succeeding X-Git-Tag: 0.1~403 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b88534374824ff592b73d71da6766b53ab706bf;p=thirdparty%2Fdracut.git Fix find_binary always succeeding find_binary inside dracut-functions always succeeds. Independent of whether the file actually exists or not. This patch fixes this. And since we're using the function not only to find binaries at little enhancement there shouldn't be that bad either. -- dracut-functions | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) --- diff --git a/dracut-functions b/dracut-functions index 56b375750..7bb042f51 100755 --- a/dracut-functions +++ b/dracut-functions @@ -53,15 +53,26 @@ inst_library() { fi } -find_binary() { - local binpath="/bin /sbin /usr/bin /usr/sbin" p - [[ ${1##*/} = $1 ]] || { echo $1; return 0; } +find_file() { + local binpath="/bin /sbin /usr/bin /usr/sbin" p + + #Full path or not? + if [[ ${1##*/} != $1 ]] ; then + if [[ -e $1 ]] ; then + echo $1; + return 0; + fi + return 1; + fi + #Search in path for p in $binpath; do - [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; } + [[ -x $p/$1 ]] && { echo "$p/$1"; return 0; } + [[ -e $p/$1 ]] && { echo "$p/$1"; return 0; } done return 1 } + # Same as above. # If the file is a binary executable, install all its # shared library dependencies, if any. @@ -134,7 +145,7 @@ inst() { echo "usage: inst []" return 1 fi - local src=$(find_binary "$1") || { + local src=$(find_file "$1") || { echo "Cannot find requested file $1. Exiting." exit 1 }