home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 26.ddi / root.3 / usr / ucb / which < prev   
Encoding:
Text File  |  1990-12-20  |  1.2 KB  |  49 lines

  1. #! /usr/bin/csh -f
  2. #ident    "@(#)//usr/ucb/which.sl 1.1 4.0 12/08/90 24762 AT&T-USL"
  3. #
  4. #
  5. #       which : tells you which program you get
  6. #
  7. # Set prompt so .cshrc will think we're interactive and set aliases.
  8. # Save and restore path to prevent .cshrc from messing it up.
  9. set _which_saved_path_ = ( $path )
  10. set prompt = ""
  11. if ( -r ~/.cshrc && -f ~/.cshrc ) source ~/.cshrc
  12. set path = ( $_which_saved_path_ )
  13. unset prompt _which_saved_path_
  14. set noglob
  15. foreach arg ( $argv )
  16.     set alius = `alias $arg`
  17.     switch ( $#alius )
  18.         case 0 :
  19.             breaksw
  20.         case 1 :
  21.             set arg = $alius[1]
  22.             breaksw
  23.         default :
  24.             echo ${arg}: "      " aliased to $alius
  25.             continue
  26.     endsw
  27.     unset found
  28.     if ( $arg:h != $arg:t ) then
  29.         if ( -e $arg ) then
  30.             echo $arg
  31.         else
  32.             echo $arg not found
  33.         endif
  34.         continue
  35.     else
  36.         foreach i ( $path )
  37.             if ( -x $i/$arg && ! -d $i/$arg ) then
  38.                 echo $i/$arg
  39.                 set found
  40.                 break
  41.             endif
  42.         end
  43.     endif
  44.     if ( ! $?found ) then
  45.         echo no $arg in $path
  46.     endif
  47. end
  48.  
  49.