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, andzshall skip over non-executable files in$PATHwhen executing a command. However, the behavior ofcommand -vis 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 inzsh, 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.