chiark / gitweb /
Cope with absolute file names (Debian bugs #162837 and #162967).
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 1 Oct 2002 11:40:14 +0000 (11:40 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 1 Oct 2002 11:40:14 +0000 (11:40 +0000)
pwhich

diff --git a/pwhich b/pwhich
index 807880c..bf877c2 100755 (executable)
--- 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