Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [patch] "which"-builtin writes diagnostics to stdout

On Tue, Sep 1, 2015 at 8:04 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Aug 30,  7:26am, Timo Buhrmester wrote:
> } Subject: Re: [patch] "which"-builtin writes diagnostics to stdout
> }
> } > > | % which doesnotexist
> } > > | doesnotexist not found
> } > >
> } > > the "doesnotexist not found" message goes to standard output,
> } > > rather than standard error.
> }
> } Out of curiosity, what reason would zsh (being more bourne-ish than
> } csh-ish, as far as I can tell) have to maintain this particular csh
> } glitch rather than fixing it?
> What makes you think it's a glitch?
> I.e., "not found" here is not an error message!  It is the answer to the
> question you asked, and you asked for the answer in csh format ("which"
> is "whence -c").  If you don't want csh behavior, you should be using
> "whence" directly so that you can omit the "-c" option.

I guess the problem here is that in other shells, whence does not
exist, and which prints 'not found' to stderr. Zsh's which acts like
the csh variant even in the sh emulation, so finding the absolute path
of a command portably is pretty difficult. (In bash, both type and
which print 'not found' on stderr. In dash, which prints to stderr and
type prints to stdout. In zsh both print to stdout. type additionally
prints the extra 'foo is' first so it's less useful).

Mikael Magnusson

Messages sorted by: Reverse Date, Date, Thread, Author