Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Mar 2000 11:13:23 -0500
From:      Garance A Drosihn <drosih@rpi.edu>
To:        Laurence Berland <stuyman@confusion.net>, Chuck Robey <chuckr@picnic.mat.net>
Cc:        Alfred Perlstein <bright@wintelcom.net>, Dan Papasian <bugg@bugg.strangled.net>, current@FreeBSD.ORG
Subject:   Re: which(1), rewritten in C?
Message-ID:  <v0421010db4e5929ddd15@[128.113.24.47]>
In-Reply-To: <38BF334F.2F10D4B0@confusion.net>
References:  <Pine.BSF.4.21.0003022232310.301-100000@picnic.mat.net> <38BF334F.2F10D4B0@confusion.net>

next in thread | previous in thread | raw e-mail | index | archive | help
At 10:36 PM -0500 3/2/00, Laurence Berland wrote:
>Which is also a perl script, which sh uses (since it's not a builtin
>there).  It does the same thing as the 'which' that's built in to bash
>and tcsh and csh

If you do a 'type -a which' or 'help which' in bash, you'll find that
'which' is not a built-in function in bash either.  Sh/bash people
would be more likely to use 'type blah' or 'type -a blah' instead
of 'which blah'.

(at least, it isn't a built-in function on my machine...)

Having used csh for awhile before switching to bash, and also not
thrilled with /usr/bin/which, I have a function for it in my bashrc:

function which {
    local which_temp
    while [ "$1" ]; do
       which_temp=`type -type $1`
       if [ "$which_temp" = "file" ]; then
          type -path $1
       else
          if [ "$which_temp" ]; then
             type -all $1
          else
             echo no $1 in $PATH
          fi
       fi
       shift
    done
}

That's just included for amusement purposes (and I'm not sure it
behaves exactly the way 'which' would in csh).  I do like the idea
of /usr/bin/which being rewritten into C...


---
Garance Alistair Drosehn           =   gad@eclipse.acs.rpi.edu
Senior Systems Programmer          or  drosih@rpi.edu
Rensselaer Polytechnic Institute


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v0421010db4e5929ddd15>