From: Colin Watson Date: Tue, 1 Oct 2002 11:40:14 +0000 (+0000) Subject: Cope with absolute file names (Debian bugs #162837 and #162967). X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=commitdiff_plain;h=56cdeb76285342e9d07f847e6df9868821e9bd3f;ds=sidebyside Cope with absolute file names (Debian bugs #162837 and #162967). --- diff --git a/pwhich b/pwhich index 807880c..bf877c2 100755 --- a/pwhich +++ b/pwhich @@ -5,13 +5,23 @@ RET=1 for PROGRAM in "$@"; do IFS_SAVE="$IFS" IFS=: - for ELEMENT in $PATH; do - if [ -f "$ELEMENT/$PROGRAM" ] && [ -x "$ELEMENT/$PROGRAM" ]; then - echo "$ELEMENT/$PROGRAM" - RET=0 - break - fi - done + case $PROGRAM in + */*) + if [ -x "$PROGRAM" ]; then + echo "$PROGRAM" + RET=0 + fi + ;; + *) + for ELEMENT in $PATH; do + if [ -x "$ELEMENT/$PROGRAM" ]; then + echo "$ELEMENT/$PROGRAM" + RET=0 + break + fi + done + ;; + esac IFS="$IFS_SAVE" done