BSD 3 development
[unix-history] / usr / src / cmd / which.sh
CommitLineData
d49de565
BJ
1#
2# which : tells you which program you get
3# hacked to do aliases (from .cshrc file only!)
4set noglob
5foreach arg ( $argv )
6 set alius = `alias $arg`
7 switch ( $#alius )
8 case 0 :
9 breaksw
10 case 1 :
11 set arg = $alius[1]
12 breaksw
13 default :
14 echo ${arg}: " " aliased to $alius
15 continue
16 endsw
17 unset found
18 if ( $arg:h != $arg:t ) then
19 if ( -e $arg ) then
20 echo $arg
21 else
22 echo $arg not found
23 endif
24 continue
25 else
26 foreach i ( $path )
27 if ( -x $i/$arg && ! -d $i/$arg ) then
28 echo $i/$arg
29 set found
30 break
31 endif
32 end
33 endif
34 if ( ! $?found ) then
35 echo no $arg in $path
36 endif
37end