date and time created 83/03/09 16:23:32 by ralph
[unix-history] / usr / src / old / which / which.csh
CommitLineData
e6f0788d 1#! /bin/csh -f
c085d0f6 2#
e6f0788d 3# @(#)which.csh 4.2 (Berkeley) 83/02/14
c085d0f6
KM
4#
5# which : tells you which program you get
e6f0788d 6#
c085d0f6
KM
7set noglob
8foreach arg ( $argv )
9 set alius = `alias $arg`
10 switch ( $#alius )
11 case 0 :
12 breaksw
13 case 1 :
14 set arg = $alius[1]
15 breaksw
16 default :
17 echo ${arg}: " " aliased to $alius
18 continue
19 endsw
20 unset found
21 if ( $arg:h != $arg:t ) then
22 if ( -e $arg ) then
23 echo $arg
24 else
25 echo $arg not found
26 endif
27 continue
28 else
29 foreach i ( $path )
30 if ( -x $i/$arg && ! -d $i/$arg ) then
31 echo $i/$arg
32 set found
33 break
34 endif
35 end
36 endif
37 if ( ! $?found ) then
38 echo no $arg in $path
39 endif
40end