Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!stc!datlog!torch!igp From: igp@torch.co.uk (Ian Phillipps) Newsgroups: alt.sources Subject: Re: fast which v3.0. A shorter method Message-ID: <605@torch.co.uk> Date: 12 Jan 90 09:25:33 GMT References: <5051@solo9.cs.vu.nl> Organization: Torch Technology Ltd., Cambridge, England Lines: 26 IMHO, this is just as quick, and a bit shorter. Note the (brackets) in the alias: this executes in a fork of your login shell and prevents the parameters creeping into your environment. You'll want to put in a complete path name instead of which.src. BUGS: you can't do `which foo` cat <<'END_OF_SHAR' >which.src # execute as a "sourced" file # Parameter WhichWhich is set to name list to be scanned # Set up with: # alias which '(set WhichWhich=(\!*); source which.src )' foreach x ( $WhichWhich ) set TempWhich=`alias $x`; if ( $#TempWhich > 0 ) echo alias: $x "'$TempWhich'" # if ( $#TempWhich > 0 ) break # Break here if only foreach f ($path) if ( -f $f/$x ) then echo $f/$x # break # Break here if only one filename wanted endif end end END_OF_SHAR exit