All pastes #39535 Raw Edit

Someone

public text v1 · immutable
#39535 ·published 2006-02-01 22:17 UTC
rendered paste body
PATH='/bin:/usr/bin:/usr/local/bin'
set -x
_which () {
    if test 1 -ne $#
    then
        echo 'Wrong number of arguments.' 2>&1
        return 1
    else
        ATH="${PATH}:"
        while test -n "$ATH"
        do
            P="${ATH%%:*}"      # first element
            ATH="${ATH#*:}"     # rest of elements
            if test -x "$P/$1"
            then return 0
            fi
        done
        return 1                # nothing found, give up
    fi
}
_which sh || echo broken
_which SH && echo broken