home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / ucb / which < prev    next >
Text File  |  1997-03-28  |  758b  |  46 lines

  1. #!/bin/csh -f
  2. set prompt = "% "
  3. if ( -f ~/.cshrc) then
  4.     source ~/.cshrc
  5. endif
  6. set noglob
  7. foreach arg ( $argv )
  8.     set alius = `alias $arg`
  9.     switch ( $#alius )
  10.     case 0 :
  11.         breaksw
  12.     case 1 :
  13.         set arg = $alius[1]
  14.         breaksw
  15.         default :
  16.         echo ${arg}: "    " aliased to $alius
  17.         continue
  18.     endsw
  19.     unset found
  20.     if ( $arg:h != $arg:t ) then
  21.     if ( -e $arg ) then
  22.         echo $arg
  23.     else
  24.         echo $arg not found
  25.     endif
  26.     continue
  27.     else
  28.     foreach i ( $path )
  29.         if ( -x $i/$arg && ! -d $i/$arg ) then
  30.         echo $i/$arg
  31.         set found
  32.         break
  33.         endif
  34.         if ( -d $i/$arg.app && -x $i/$arg.app/$arg ) then
  35.         echo $i/$arg.app/$arg
  36.         set found
  37.         break
  38.         endif
  39.     end
  40.  
  41.     endif
  42.     if ( ! $?found ) then
  43.     echo no $arg in $path
  44.     endif
  45. end
  46.