From: tfheen Date: Wed, 19 Jan 2005 13:17:55 +0000 (+0000) Subject: do the path search ourselves X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e1bf48bd8b564ca2b1033af579e80ef4cb638ea;p=dotfiles do the path search ourselves git-svn-id: file:///svn/tfheen/trunk/dotfiles@723 8da78d58-1cd3-0310-bee5-d77bd1b3e8bf --- 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 () {