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