From 7e1bf48bd8b564ca2b1033af579e80ef4cb638ea Mon Sep 17 00:00:00 2001 From: tfheen Date: Wed, 19 Jan 2005 13:17:55 +0000 Subject: [PATCH] do the path search ourselves git-svn-id: file:///svn/tfheen/trunk/dotfiles@723 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf --- environment | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/environment b/environment index c73c250..1d562fe 100644 --- a/environment +++ b/environment @@ -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 () { -- 2.39.5