xref: /csrg-svn/old/which/which.csh (revision 22409)
1*22409Sdist#!/bin/csh -f
211059Smckusick#
3*22409Sdist# Copyright (c) 1980 Regents of the University of California.
4*22409Sdist# All rights reserved.  The Berkeley software License Agreement
5*22409Sdist# specifies the terms and conditions for redistribution.
611059Smckusick#
7*22409Sdist#	@(#)which.csh	5.1 (Berkeley) 06/06/85
8*22409Sdist#
911059Smckusick#	which : tells you which program you get
1011060Smckusick#
1118283Smckusickset prompt = "% "
1218283Smckusicksource ~/.cshrc
1311059Smckusickset noglob
1411059Smckusickforeach arg ( $argv )
1511059Smckusick    set alius = `alias $arg`
1611059Smckusick    switch ( $#alius )
1711059Smckusick	case 0 :
1811059Smckusick	    breaksw
1911059Smckusick	case 1 :
2011059Smckusick	    set arg = $alius[1]
2111059Smckusick	    breaksw
2211059Smckusick        default :
2311059Smckusick	    echo ${arg}: "	" aliased to $alius
2411059Smckusick	    continue
2511059Smckusick    endsw
2611059Smckusick    unset found
2711059Smckusick    if ( $arg:h != $arg:t ) then
2811059Smckusick	if ( -e $arg ) then
2911059Smckusick	    echo $arg
3011059Smckusick	else
3111059Smckusick	    echo $arg not found
3211059Smckusick	endif
3311059Smckusick	continue
3411059Smckusick    else
3511059Smckusick	foreach i ( $path )
3611059Smckusick	    if ( -x $i/$arg && ! -d $i/$arg ) then
3711059Smckusick		echo $i/$arg
3811059Smckusick		set found
3911059Smckusick		break
4011059Smckusick	    endif
4111059Smckusick	end
4211059Smckusick    endif
4311059Smckusick    if ( ! $?found ) then
4411059Smckusick	echo no $arg in $path
4511059Smckusick    endif
4611059Smckusickend
47