According to the documentation for which
, it should "list all instances of executables" (-a
) "in the user's path", and based on my understanding of what executables are and what a path is, that means, simply that the first listed item should be the one executed when I enter the name of the searched for command.
But that's not the behavior I'm seeing.
~ $ which -a speedtest
/usr/local/bin/speedtest
~ $ speedtest -V
curl 7.64.1 (x86_64-apple-darwin20.0) ...
~ $ /usr/local/bin/speedtest -V
Speedtest by Ookla 1.0.0.2 (5ae238b) Darwin 20.4.0 x86_64
I expect that the speedtest
returned first by which (Ookla's) would be the one that's found first and executed but it's not and a different one (curl's) is executed instead. Moreover, the speedtest
that is excited isn't even retuned by which
at all.
What's going on here? How is this even possible? Why isn't which -a
listing the excitable that will run?
~ $ ls -al /usr/local/bin/speedtest
lrwxr-xr-x 1 Orome admin 39 May 18 13:51 /usr/local/bin/speedtest -> ../Cellar/speedtest/1.0.0/bin/speedtest
~ $ /usr/local/bin/../Cellar/speedtest/1.0.0/bin/speedtest -V
Speedtest by Ookla 1.0.0.2 (5ae238b) Darwin 20.4.0 x86_64 ...
~ $ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-apple-darwin20.3.0) ...
~ $ echo $PATH
/usr/local/opt/python@3.9/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/sbin
~ $ whereis speedtest