3

According to this comment which is in defense of the author's answer,

@einpoklum Yes, it is necessary. In fact, even this solution may break in one edge case. Thanks for bringing this to my attention. dash, bash, and zsh all skip over non-executable files in $PATH when executing a command. However, the behavior of command -v is very inconsistent. In dash, it returns the first matching file in $PATH, regardless of whether it's executable or not. In bash, it returns the first executable match in $PATH, but if there's none, it can return a non-executable file. And in zsh, it will never return a non-executable file. – nyuszika7h Oct 26 at 13:52

Is this documented anywhere but in this question? Is the behavior of command spec'ed anywhere?

Trying with bash, I can't see it returning a non-executable file. I've tried.

Evan Carroll
  • 30,763
  • 48
  • 183
  • 315
  • 1
    You may want to look at this https://unix.stackexchange.com/a/85250/38906 – cuonglm Nov 13 '17 at 03:18
  • 1
    @cuonglm wow, it's a shame that history lesson/book isn't split across 5 more appropriately titled quesitons. But, yeah, that has 100% of what I'm looking for. – Evan Carroll Nov 13 '17 at 04:09
  • 1
    Yes, here's the spec: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html – Alexia Luna Nov 13 '17 at 11:06

0 Answers0