which Revision 383033656437 (Sun Jul 26 2009 at 08:48) - Diff Link to this snippet: https://friendpaste.com/2EDSrXga87MbNg9X57olqU Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#! /bin/shset -efALLMATCHES=0while getopts a whichoptsdo case "$whichopts" in a) ALLMATCHES=1 ;; ?) printf "Usage: %s [-a] args\n" $0 ; exit 2 ;; esacdoneshift $(($OPTIND - 1))if [ "$#" -eq 0 ]; then ALLRET=1else ALLRET=0ficase $PATH in *::) : "not *DIR:" ;; *:) PATH="$PATH:" ;;esacfor PROGRAM in "$@"; do RET=1 IFS_SAVE="$IFS" IFS=: case $PROGRAM in */*) if [ -f "$PROGRAM" ] && [ -x "$PROGRAM" ]; then printf '%s\n' "$PROGRAM" RET=0 fi ;; *) for ELEMENT in $PATH; do if [ -z "$ELEMENT" ]; then ELEMENT=. fi if [ -f "$ELEMENT/$PROGRAM" ] && [ -x "$ELEMENT/$PROGRAM" ]; then printf '%s\n' "$ELEMENT/$PROGRAM" RET=0 [ "$ALLMATCHES" -eq 1 ] || break fi done ;; esac IFS="$IFS_SAVE" if [ "$RET" -ne 0 ]; then ALLRET=1 fidoneexit "$ALLRET"