From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43527-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 28eefcdc for ; Mon, 24 Sep 2018 13:02:05 +0000 (UTC) Received: (qmail 8673 invoked by alias); 24 Sep 2018 13:01:54 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43527 Received: (qmail 18413 invoked by uid 1010); 24 Sep 2018 13:01:54 -0000 X-Qmail-Scanner-Diagnostics: from mailout1.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.11):SA:0(-7.5/5.0):. Processed in 3.398026 secs); 24 Sep 2018 13:01:54 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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= X-AuditID: cbfec7f5-79db79c0000012c6-c3-5ba8ddce8b53 Date: Mon, 24 Sep 2018 13:51:24 +0100 From: Peter Stephenson To: Zsh Workers Subject: Re: BUG: Shell builtin `which` prints non-existent commands to stdout In-Reply-To: <20180924122933.gpzp4vfix6zl66nw@klaus.seistrup.dk> Organization: SCSC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLIsWRmVeSWpSXmKPExsWy7djPc7rn7q6INji5UcXiYPNDJgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZdx7MpGl4KlgxZIvH1kbGD/ydjFyckgImEi8fP+WBcQWEljB KLF7lUkXIxeQ3cckcWVLLztEopdJ4toCU5iG7t03GSGKljNK/Lu4mRWuaPotC4jEGUaJT3OX sEM4FxglOu/9YgSpYhFQldi27QATiM0mYCgxddNssLgIUPz3trtsILawQIDEs5udYDWcAg4S 1yasBKrh4OAXEJK40GwLcYW9xNE9J8FKeAUEJU7OfAL2ArOAvMT2t3OYQfZKCLxnk3jwdR4b RFGZxI5lm1kgml0kGjbtZYSwhSVeHd/CDmHLSPzfOZ8JormdUWLNpNfsEE4Po8Smo3egOqwl +m5fBLuIWUBTYv0ufYiwo0Tnq0dsIGEJAT6JG28FIQ7ik5i0bTozRJhXoqNNCKJaTWJH01bG CYzKs5C8MAvJC7MQ5i9gZF7FKJ5aWpybnlpsnJdarlecmFtcmpeul5yfu4kRmAhO/zv+dQfj vj9JhxgFOBiVeHgZ7i2PFmJNLCuuzD3EKMHBrCTC63YLKMSbklhZlVqUH19UmpNafIhRmoNF SZyXTystWkggPbEkNTs1tSC1CCbLxMEp1cC460KB89ZZG200Yh3vlvjbadvnN/HzHovxz3ph 5XH+/ZXDtpYzBT5n3MloZv0tLCDwOODTPKc2L4HDN8peMXBs7b1y0T/zwole44oi60TPl1Pn aqh3B9h9D9Xf++2uBeOsKznvwrc49RhvXSyacXHFm385a/Q+7eyME/kRfE7D8JKB44WiHSpK LMUZiYZazEXFiQDcpdl9AAMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42I5/e/4Pd2zd1dEG1yfpWVxsPkhkwOjx6qD H5gCGKP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLLUov07RL0 Mu49mchS8FSwYsmXj6wNjB95uxg5OSQETCS6d99k7GLk4hASWMoosevLBSaIhIzEpysf2SFs YYk/17rYIIq6mSQO919nh3DOMErcenqXFcK5wCjxbdcpFpAWFgFViW3bDoCNYhMwlJi6aTYj iC0CFP+97S4biC0sECDx7GYnWA2vgLPE1/tbwXo5BRwkrk1YCXXTNiaJ5s0fmbsYOTj4BYQk LjTbQpxkL3F0z0moXkGJkzOfgPUyC+hInFh1jBnClpfY/nYO8wRG4VlIymYhKZuFpGwBI/Mq RpHU0uLc9NxiQ73ixNzi0rx0veT83E2MwLjYduzn5h2MlzYGH2IU4GBU4uFluLc8Wog1say4 MvcQowQHs5IIr9stoBBvSmJlVWpRfnxRaU5q8SFGU2BgTGSWEk3OB8ZsXkm8oamhuYWlobmx ubGZhZI473mDyighgfTEktTs1NSC1CKYPiYOTqkGxuCrT//3byt3n7HAxTBD6/+Dh5Fvvaxf ap1+We8nJBq9xLiyvr/AImCfTvvbTzd3N3P9XN/RcuOY+lnuF99nbLPk2P/Kgi1rRrfWcl85 x5dpR4zd2Dk5tq5W8EzU0PovIPFs+dnC7gMhE74ZsdUnelbbsUyv8Yh//e9I5sdAfh1RRV3N 6Bt/lFiKMxINtZiLihMBWLz5wqECAAA= Message-Id: <20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae~XVwcoX7b91518615186eucas1p2T@eucas1p2.samsung.com> X-CMS-MailID: 20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20180924080113epcas4p4f8f89aa03a2cebc5030fd45dca0f6e84 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180924080113epcas4p4f8f89aa03a2cebc5030fd45dca0f6e84 References: <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 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)