From: Colin Watson Date: Mon, 23 Sep 2002 13:31:09 +0000 (+0000) Subject: pwhich: A portable (I believe) /bin/sh implementation of 'which'. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=commitdiff_plain;h=9b218e3408d6544bfce111bfe48746b9444285c6 pwhich: A portable (I believe) /bin/sh implementation of 'which'. --- diff --git a/pwhich b/pwhich new file mode 100644 index 0000000..47aa80c --- /dev/null +++ b/pwhich @@ -0,0 +1,17 @@ +#! /bin/sh -e + +RET=1 +for PROGRAM in "$@"; do + IFS_SAVE="$IFS" + IFS=: + for ELEMENT in $PATH; do + if [ -f "$ELEMENT/$PROGRAM" -a -x "$ELEMENT/$PROGRAM" ]; then + echo "$ELEMENT/$PROGRAM" + RET=0 + break + fi + done + IFS="$IFS_SAVE" +done + +exit "$RET"