Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: BUG: Shell builtin `which` prints non-existent commands to stdout
- X-seq: zsh-workers 43527
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Workers <zsh-workers@xxxxxxx>
- Subject: Re: BUG: Shell builtin `which` prints non-existent commands to stdout
- Date: Mon, 24 Sep 2018 13:51:24 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180924125128euoutp014cef7265c133f70833cee378f8b7211c~XVwefioM42380423804euoutp01V
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537793488; bh=dfKHGDCfs91ZY+ZnzQsPIKnj/1Uvz+PWCc2FTb2B/T0=; h=Date:From:To:Subject:In-Reply-To:References:From; b=nAyebiS79kX0VeLCPgajFhAEGaLZ/SCQU1Dqnv6dKebQiQopOB9UEY2sC50kxL//o ixyR2sZb8ndIeErGWqZGdBoTVJYIe3AVRH6w4Isp6DL8lru7LO5gmQ9v0t1dqxdHRZ j3k8hGOYB1kK/suUcyH6mXNyY/b6ivYlpdCmxIHk=
- In-reply-to: <20180924122933.gpzp4vfix6zl66nw@klaus.seistrup.dk>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180924080113epcas4p4f8f89aa03a2cebc5030fd45dca0f6e84@epcas4p4.samsung.com> <20180924080031.ee7lqmthxpmvqaal@klaus.seistrup.dk> <20180924102219eucas1p2469f827265423a2f3b5e7d98fc08412e~XTuQ1aIyy2293622936eucas1p2L@eucas1p2.samsung.com> <20180924122933.gpzp4vfix6zl66nw@klaus.seistrup.dk>
On Mon, 24 Sep 2018 14:29:33 +0200
Klaus Alexander Seistrup <klaus@xxxxxxxxxxx> wrote:
> Peter Stephenson wrote:
>
> > This is not a bug and has been discussed numerous times
>
> Thanks, I hadn't see that. I'll just keep the `which` alias, then.
Might be useful to make the issue more visible...
diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index a3dfc6c..e15e024 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -127,6 +127,7 @@ Chapter 3: How to get various things to work
3.26. Why is my output duplicated with `tt(foo 2>&1 >foo.out | bar)'?
3.27. What are these `^' and `~' pattern characters, anyway?
3.28. How do I edit the input buffer in $EDITOR?
+3.29. Why does `which' output for missing commands go to stdout?
Chapter 4: The mysteries of completion
4.1. What is completion?
@@ -1964,6 +1965,34 @@ label(328)
quitting the editor will only return to zsh's command-line editing mode.
+sect(Why does `which' output for missing commands go to stdout?)
+
+ The issue is that if you run:
+ verb(
+ which non-existent-command
+ )
+ the error message goes, unusually, to standard output rather than
+ to standard error. Other shells send this message to standard error,
+ as they would if the command was about to be executed but could not be
+ found.
+
+ The original reason for this is that this behaviour is inherited
+ from the C shell (csh), where `tt(which)' itself orignated. So
+ it has been in zsh a very long time, and it is now a feature.
+ (It would be possible to change this in emulation modes; however.
+ so far this possibility has been seen has more of an additional
+ confusion than a help.)
+
+ If you want some further rationalisation, which may be what the C
+ shell designers had in mind, you might note that `tt(which)' is
+ designed as a way of outputing information about a command. So
+ `this command can be found in ...' and `this command can't be found'
+ are both bits of information here, unlike the case where the command
+ is to be executed. So although it differs from other Bourne-style
+ shells it is in fact self-consistent. Note that the status does
+ reflect the fact the command can't be found.
+
+
chapter(The mysteries of completion)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author