xref: /original-bsd/old/which/which.csh (revision 4ad1d170)
1#! /bin/csh -f
2#
3#	@(#)which.csh	4.4	(Berkeley)	85/03/11
4#
5#	which : tells you which program you get
6#
7set prompt = "% "
8source ~/.cshrc
9set noglob
10foreach arg ( $argv )
11    set alius = `alias $arg`
12    switch ( $#alius )
13	case 0 :
14	    breaksw
15	case 1 :
16	    set arg = $alius[1]
17	    breaksw
18        default :
19	    echo ${arg}: "	" aliased to $alius
20	    continue
21    endsw
22    unset found
23    if ( $arg:h != $arg:t ) then
24	if ( -e $arg ) then
25	    echo $arg
26	else
27	    echo $arg not found
28	endif
29	continue
30    else
31	foreach i ( $path )
32	    if ( -x $i/$arg && ! -d $i/$arg ) then
33		echo $i/$arg
34		set found
35		break
36	    endif
37	end
38    endif
39    if ( ! $?found ) then
40	echo no $arg in $path
41    endif
42end
43