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