1*7c478bd9Sstevel@tonic-gate#! /usr/bin/csh -f 2*7c478bd9Sstevel@tonic-gate# 3*7c478bd9Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 4*7c478bd9Sstevel@tonic-gate# Use is subject to license terms. 5*7c478bd9Sstevel@tonic-gate# 6*7c478bd9Sstevel@tonic-gate# Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate# All rights reserved. The Berkeley Software License Agreement 8*7c478bd9Sstevel@tonic-gate# specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate# 10*7c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 11*7c478bd9Sstevel@tonic-gate# 12*7c478bd9Sstevel@tonic-gate# which : tells you which program you get 13*7c478bd9Sstevel@tonic-gate# 14*7c478bd9Sstevel@tonic-gate# Set prompt so .cshrc will think we're interactive and set aliases. 15*7c478bd9Sstevel@tonic-gate# Save and restore path to prevent .cshrc from messing it up. 16*7c478bd9Sstevel@tonic-gateset _which_saved_path_ = ( $path ) 17*7c478bd9Sstevel@tonic-gateset prompt = "" 18*7c478bd9Sstevel@tonic-gateif ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc 19*7c478bd9Sstevel@tonic-gateset path = ( $_which_saved_path_ ) 20*7c478bd9Sstevel@tonic-gateunset prompt _which_saved_path_ 21*7c478bd9Sstevel@tonic-gateset noglob 22*7c478bd9Sstevel@tonic-gateset exit_status = 0 23*7c478bd9Sstevel@tonic-gateforeach arg ( $argv ) 24*7c478bd9Sstevel@tonic-gate set alius = `alias $arg` 25*7c478bd9Sstevel@tonic-gate switch ( $#alius ) 26*7c478bd9Sstevel@tonic-gate case 0 : 27*7c478bd9Sstevel@tonic-gate breaksw 28*7c478bd9Sstevel@tonic-gate case 1 : 29*7c478bd9Sstevel@tonic-gate set arg = $alius[1] 30*7c478bd9Sstevel@tonic-gate breaksw 31*7c478bd9Sstevel@tonic-gate default : 32*7c478bd9Sstevel@tonic-gate echo ${arg}: " " aliased to $alius 33*7c478bd9Sstevel@tonic-gate continue 34*7c478bd9Sstevel@tonic-gate endsw 35*7c478bd9Sstevel@tonic-gate unset found 36*7c478bd9Sstevel@tonic-gate if ( "$arg:h" != "$arg:t" ) then # head != tail, don't search 37*7c478bd9Sstevel@tonic-gate if ( -e $arg ) then # just do simple lookup 38*7c478bd9Sstevel@tonic-gate echo $arg 39*7c478bd9Sstevel@tonic-gate else 40*7c478bd9Sstevel@tonic-gate echo $arg not found 41*7c478bd9Sstevel@tonic-gate set exit_status = 1 42*7c478bd9Sstevel@tonic-gate endif 43*7c478bd9Sstevel@tonic-gate continue 44*7c478bd9Sstevel@tonic-gate else 45*7c478bd9Sstevel@tonic-gate foreach i ( $path ) 46*7c478bd9Sstevel@tonic-gate if ( -x $i/$arg && ! -d $i/$arg ) then 47*7c478bd9Sstevel@tonic-gate echo $i/$arg 48*7c478bd9Sstevel@tonic-gate set found 49*7c478bd9Sstevel@tonic-gate break 50*7c478bd9Sstevel@tonic-gate endif 51*7c478bd9Sstevel@tonic-gate end 52*7c478bd9Sstevel@tonic-gate endif 53*7c478bd9Sstevel@tonic-gate if ( ! $?found ) then 54*7c478bd9Sstevel@tonic-gate echo no $arg in $path 55*7c478bd9Sstevel@tonic-gate set exit_status = 1 56*7c478bd9Sstevel@tonic-gate endif 57*7c478bd9Sstevel@tonic-gateend 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gateexit ${exit_status} 60*7c478bd9Sstevel@tonic-gate 61