which and PATH
Stephen Ryan
stephen at sryanfamily.info
Thu Dec 6 17:16:21 EST 2007
On Thu, 2007-12-06 at 17:03 -0500, Kent Johnson wrote:
> Can someone please explain this to me?
>
> kent $ which curl
> /opt/local/bin/curl
>
> So if I run curl, I should get /opt/local/bin/curl, right? But I seem to
> get /usr/bin/curl:
>
> kent $ /opt/local/bin/curl -V
> curl 7.17.1 (i386-apple-darwin8.11.1) libcurl/7.17.1 zlib/1.2.3
>
> kent $ curl -V
> curl 7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l
>
> kent $ /usr/bin/curl -V
> curl 7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l
>
> /opt/local/bin is ahead of /usr/bin/ in PATH:
>
> kent $ echo $PATH$
> /Users/kent/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/bin:/sbin:/usr/bin:/usr/sbin$
>
> AFAICT there is no curl ahead of /opt/local/bin/curl in PATH:
> kent $ ls /Users/kent/bin/curl
> ls: /Users/kent/bin/curl: No such file or directory
> kent $ ls /usr/local/bin/curl
> ls: /usr/local/bin/curl: No such file or directory
> kent $ ls /opt/local/bin/curl
> /opt/local/bin/curl
>
> This is on Mac OSX, if it matters.
>
You didn't happen to have installed /opt/local/bin/curl during this
session, did you? I'm guessing that you're running into the fact that
bash caches the PATH location where it last found each binary; run 'hash
-r' to make it clear the cache.
--
Stephen Ryan
Dartware, LLC
More information about the gnhlug-discuss
mailing list