title: Why isn't 'which -a' listing the executable that will run?
body: <p>According to the documentation for <code>which</code>, it should &quot;list all instances of executables&quot; (<code>-a</code>) &quot;in the user's path&quot;, 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.</p>
  <p>But that's not the behavior I'm seeing.</p>
  <pre class="lang-sh prettyprint-override"><code>~ $ 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
  </code></pre>
  <p>I expect that the <code>speedtest</code> 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 <code>speedtest</code> that is excited isn't even retuned by <code>which</code> at all.</p>
  <p>What's going on here? How is this even possible? Why isn't <code>which -a</code> listing the excitable that will run?</p>
  <hr />
  <pre class="lang-sh prettyprint-override"><code>~ $ ls -al /usr/local/bin/speedtest
  lrwxr-xr-x  1 Orome  admin  39 May 18 13:51 /usr/local/bin/speedtest -&gt; ../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 ...
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>~ $ bash --version
  GNU bash, version 5.1.8(1)-release (x86_64-apple-darwin20.3.0) ...
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>~ $ 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
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>~ $ whereis speedtest
  
  </code></pre>