config.tests/unix/which.test
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 #!/bin/sh
       
     2 
       
     3 HOME=/dev/null
       
     4 export HOME
       
     5 
       
     6 unset which
       
     7 
       
     8 WHICH=`which which 2>/dev/null`
       
     9 if echo $WHICH | grep 'shell built-in command' >/dev/null 2>&1; then
       
    10     WHICH=which
       
    11 elif [ -z "$WHICH" ]; then
       
    12     if which which >/dev/null 2>&1; then
       
    13 	WHICH=which
       
    14     else
       
    15 	for a in /usr/ucb /usr/bin /bin /usr/local/bin; do
       
    16 	    if [ -x $a/which ]; then
       
    17 		WHICH=$a/which
       
    18 		break;
       
    19 	    fi
       
    20 	done
       
    21     fi
       
    22 fi
       
    23 
       
    24 if [ -z "$WHICH" ]; then
       
    25     IFS=:
       
    26     for a in $PATH; do
       
    27 	if [ -x $a/$1 ]; then
       
    28 	    echo "$a/$1"
       
    29 	    exit 0
       
    30 	fi
       
    31     done
       
    32 else
       
    33     a=`"$WHICH" "$1" 2>/dev/null`
       
    34     if [ ! -z "$a" -a -x "$a" ]; then
       
    35 	echo "$a"
       
    36 	exit 0
       
    37     fi
       
    38 fi
       
    39 exit 1