Re: which: command not found
"Mark J. Reed" <[email protected]> Fri, 12 Dec 2025 17:12:55 -0500
| Newsgroups | gmane.comp.shells.zsh.user |
|---|---|
| Message-ID | <CAA=-s3z6DMCV1ScX7JXfogExG8iO4ak2tOqTZyh-OjeGe5M6xQ@mail.gmail.com> |
On Fri, Dec 12, 2025 at 12:20 PM Bart Schaefer <[email protected]> wrote: > On Fri, Dec 12, 2025 at 8:39 AM Mark J. Reed <[email protected]> wrote: > > > > Why does the "command not found" output of `which` go to stdout? > > The most recent discussion of this starts at workers/43523 from 2018, > at which point it was added to Etc/FAQ question 3.29. > ! My bad for not checking the FAQ; it did not even occur to me as a thing that would conceivably be there! So the answer is "because csh did it that way and that's where zsh got the 'which' command". Well, I guess that's why zsh also borrowed `whence` from ksh, which behaves more sensibly here. I guess a consistent cross-shell approach here would be to use `type`, check the return code, and extract the pathname from the end of the message on success. -- Mark J. Reed <[email protected]>