#!/bin/sh
# $Id: path,v 1.4 2001/12/07 19:35:56 tom Exp $
#
# Title:	path
# Author:	T.E.Dickey
# Created:	26 May 1994
#
# Function:	
#		Displays information about the user's execution PATH
#		environment variable.
#
#		If no arguments given, this script displays the names of the
#		directories in the path.  If argument is given, it is assumed
#		to be an executable name.  All matching names are displayed;
#		the first is the one that will be loaded.
#
#		Options (arguments beginning with "-") are passed to 'ls'.
#		
save_IFS="$IFS"
if [ $# = 0 ]
then
	IFS=':'
	for P in $PATH
	do
		echo $P
	done
else
	opts=""
	used="no"
	for N in $*
	do
		case $N in
		-*)
			opts="$opts $N"
			;;
		*)
			used="yes"
			IFS=':'
			for P in $PATH
			do
				if [ -f $P/$N -a -x $P/$N ]
				then
					IFS="$save_IFS"
					ls $opts "$P/$N"
					IFS=':'
				fi
			done
		esac
	done
	if [ ".$opts" != "." -a "$used" = "no" ]
	then
		IFS=':'
		for P in $PATH
		do
			IFS="$save_IFS"
			ls -d$opts "$P"
			IFS=':'
		done
	fi
fi
IFS="$save_IFS"
