]> err.no Git - dotfiles/commitdiff
do the path search ourselves
authortfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Wed, 19 Jan 2005 13:17:55 +0000 (13:17 +0000)
committertfheen <tfheen@8da78d58-1cd3-0310-bee5-d77bd1b3e8bf>
Wed, 19 Jan 2005 13:17:55 +0000 (13:17 +0000)
git-svn-id: file:///svn/tfheen/trunk/dotfiles@723 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf

environment

index c73c25040b9d8c49fbd87b22eacee258a4cff3e2..1d562fe87fae2a55ff5042d9035227c96482a785 100644 (file)
@@ -11,13 +11,24 @@ if [ `uname -s` = "FreeBSD" ] && alias | grep -q "ls="; then
 fi
 
 findcommand() {
-    notfound=1
-    while [ "$notfound" -eq "1" ]; do
-        COMMAND=$(command -v "$1")
-        notfound=$?
+    while [ "$#" -ge 1 ]; do
+        P="$PATH"
+        while [ "$P" ]; do 
+            D=${P%%:*}
+            P=${P#*:}
+            if [ "$D" = "$P" ]; then
+                P=
+            fi
+            if [ -z "$D" ]; then
+                D=.
+            fi
+            if [ -x "$D/$1" ]; then
+                echo "$D/$1"
+                return
+            fi
+        done
         shift
     done
-    echo $COMMAND
 }
 
 blog () {