xref: /csrg-svn/old/which/which.csh (revision 48332)
134016Sbostic#!/bin/csh
211059Smckusick#
334016Sbostic# DO NOT USE "csh -f"
434016Sbostic#
5*48332Sbostic# Copyright (c) 1983 The Regents of the University of California.
634025Sbostic# All rights reserved.
711059Smckusick#
8*48332Sbostic# %sccs.include.redist.sh%
922409Sdist#
10*48332Sbostic#	@(#)which.csh	5.5 (Berkeley) 04/18/91
1134025Sbostic#
12*48332Sbostic
1311059Smckusick#	which : tells you which program you get
1411060Smckusick#
1518283Smckusickset prompt = "% "
1611059Smckusickset noglob
1711059Smckusickforeach arg ( $argv )
1811059Smckusick    set alius = `alias $arg`
1911059Smckusick    switch ( $#alius )
2011059Smckusick	case 0 :
2111059Smckusick	    breaksw
2211059Smckusick	case 1 :
2311059Smckusick	    set arg = $alius[1]
2411059Smckusick	    breaksw
2511059Smckusick        default :
2611059Smckusick	    echo ${arg}: "	" aliased to $alius
2711059Smckusick	    continue
2811059Smckusick    endsw
2911059Smckusick    unset found
3011059Smckusick    if ( $arg:h != $arg:t ) then
3111059Smckusick	if ( -e $arg ) then
3211059Smckusick	    echo $arg
3311059Smckusick	else
3411059Smckusick	    echo $arg not found
3511059Smckusick	endif
3611059Smckusick	continue
3711059Smckusick    else
3811059Smckusick	foreach i ( $path )
3911059Smckusick	    if ( -x $i/$arg && ! -d $i/$arg ) then
4011059Smckusick		echo $i/$arg
4111059Smckusick		set found
4211059Smckusick		break
4311059Smckusick	    endif
4411059Smckusick	end
4511059Smckusick    endif
4611059Smckusick    if ( ! $?found ) then
4711059Smckusick	echo no $arg in $path
4811059Smckusick    endif
4911059Smckusickend
50