xref: /csrg-svn/old/which/which.csh (revision 22409)
1#!/bin/csh -f
2#
3# Copyright (c) 1980 Regents of the University of California.
4# All rights reserved.  The Berkeley software License Agreement
5# specifies the terms and conditions for redistribution.
6#
7#	@(#)which.csh	5.1 (Berkeley) 06/06/85
8#
9#	which : tells you which program you get
10#
11set prompt = "% "
12source ~/.cshrc
13set noglob
14foreach arg ( $argv )
15    set alius = `alias $arg`
16    switch ( $#alius )
17	case 0 :
18	    breaksw
19	case 1 :
20	    set arg = $alius[1]
21	    breaksw
22        default :
23	    echo ${arg}: "	" aliased to $alius
24	    continue
25    endsw
26    unset found
27    if ( $arg:h != $arg:t ) then
28	if ( -e $arg ) then
29	    echo $arg
30	else
31	    echo $arg not found
32	endif
33	continue
34    else
35	foreach i ( $path )
36	    if ( -x $i/$arg && ! -d $i/$arg ) then
37		echo $i/$arg
38		set found
39		break
40	    endif
41	end
42    endif
43    if ( ! $?found ) then
44	echo no $arg in $path
45    endif
46end
47