134016Sbostic#!/bin/csh 211059Smckusick# 334016Sbostic# DO NOT USE "csh -f" 434016Sbostic# 522409Sdist# Copyright (c) 1980 Regents of the University of California. 6*34025Sbostic# All rights reserved. 711059Smckusick# 8*34025Sbostic# Redistribution and use in source and binary forms are permitted 9*34025Sbostic# provided that this notice is preserved and that due credit is given 10*34025Sbostic# to the University of California at Berkeley. The name of the University 11*34025Sbostic# may not be used to endorse or promote products derived from this 12*34025Sbostic# software without specific prior written permission. This software 13*34025Sbostic# is provided ``as is'' without express or implied warranty. 1422409Sdist# 15*34025Sbostic# @(#)which.csh 5.4 (Berkeley) 04/19/88 16*34025Sbostic# 1711059Smckusick# which : tells you which program you get 1811060Smckusick# 1918283Smckusickset prompt = "% " 2011059Smckusickset noglob 2111059Smckusickforeach arg ( $argv ) 2211059Smckusick set alius = `alias $arg` 2311059Smckusick switch ( $#alius ) 2411059Smckusick case 0 : 2511059Smckusick breaksw 2611059Smckusick case 1 : 2711059Smckusick set arg = $alius[1] 2811059Smckusick breaksw 2911059Smckusick default : 3011059Smckusick echo ${arg}: " " aliased to $alius 3111059Smckusick continue 3211059Smckusick endsw 3311059Smckusick unset found 3411059Smckusick if ( $arg:h != $arg:t ) then 3511059Smckusick if ( -e $arg ) then 3611059Smckusick echo $arg 3711059Smckusick else 3811059Smckusick echo $arg not found 3911059Smckusick endif 4011059Smckusick continue 4111059Smckusick else 4211059Smckusick foreach i ( $path ) 4311059Smckusick if ( -x $i/$arg && ! -d $i/$arg ) then 4411059Smckusick echo $i/$arg 4511059Smckusick set found 4611059Smckusick break 4711059Smckusick endif 4811059Smckusick end 4911059Smckusick endif 5011059Smckusick if ( ! $?found ) then 5111059Smckusick echo no $arg in $path 5211059Smckusick endif 5311059Smckusickend 54