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