5172 tftpd service is not registered by default and its manual is giving misleading...
[unleashed.git] / usr / src / cmd / which / which.csh
blob023fce281cfef8a1eeb37f7ba8ec0a1ec1c1e462
1 #! /usr/bin/csh -f
3 # Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 # Use is subject to license terms.
6 # Copyright (c) 1980 Regents of the University of California.
7 # All rights reserved. The Berkeley Software License Agreement
8 # specifies the terms and conditions for redistribution.
10 #ident "%Z%%M% %I% %E% SMI"
12 # which : tells you which program you get
14 # Set prompt so .cshrc will think we're interactive and set aliases.
15 # Save and restore path to prevent .cshrc from messing it up.
16 set _which_saved_path_ = ( $path )
17 set prompt = ""
18 if ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc
19 set path = ( $_which_saved_path_ )
20 unset prompt _which_saved_path_
21 set noglob
22 set exit_status = 0
23 foreach arg ( $argv )
24 set alius = `alias $arg`
25 switch ( $#alius )
26 case 0 :
27 breaksw
28 case 1 :
29 set arg = $alius[1]
30 breaksw
31 default :
32 echo ${arg}: " " aliased to $alius
33 continue
34 endsw
35 unset found
36 if ( "$arg:h" != "$arg:t" ) then # head != tail, don't search
37 if ( -e $arg ) then # just do simple lookup
38 echo $arg
39 else
40 echo $arg not found
41 set exit_status = 1
42 endif
43 continue
44 else
45 foreach i ( $path )
46 if ( -x $i/$arg && ! -d $i/$arg ) then
47 echo $i/$arg
48 set found
49 break
50 endif
51 end
52 endif
53 if ( ! $?found ) then
54 echo no $arg in $path
55 set exit_status = 1
56 endif
57 end
59 exit ${exit_status}