From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: Zsh Workers <zsh-workers@zsh.org>
Subject: Re: BUG: Shell builtin `which` prints non-existent commands to stdout
Date: Mon, 24 Sep 2018 23:32:53 +0100 [thread overview]
Message-ID: <20180924223253.j46bxsughzy6grbf@chaz.gmail.com> (raw)
In-Reply-To: <20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae~XVwcoX7b91518615186eucas1p2T@eucas1p2.samsung.com>
2018-09-24 13:51:24 +0100, Peter Stephenson:
> On Mon, 24 Sep 2018 14:29:33 +0200
[...]
> + 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.
[...]
About "other shells" above, AFAIK, tcsh is the only other shell
that has a "which" builtin and it does also send "command not
found" to stdout. So zsh behaves like every other shells in that
regard.
To phrase my last comment differently, there are also a variety
of "which" command implementations outside of any shell, the
first of which (which appeared in 3BSD) was primarily intended
for csh users (as it read your ~/.cshrc for aliases) and was
written as a csh script that did also send the "command not
found" to stdout.
That's also the one still found on many commercial Unices.
There is also a GNU "which" command (which tries to generalise
what that csh script did for other shells) and sends the
command-not-found to stderr.
Debian has a POSIX sh which script that doesn't output any
command-not-found error and doesn't look-up aliases of any
shell (it writes the usage message on stdout followed by the
"illegal option" on stderr).
BSDs which has now been merged with whereis and been rewritten in
C and no longer looks up your csh aliases and like the Debian
script doesn't output any command-not-found error.
See also
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then
--
Stephane
next prev parent reply other threads:[~2018-09-24 22:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20180924080113epcas4p4f8f89aa03a2cebc5030fd45dca0f6e84@epcas4p4.samsung.com>
2018-09-24 8:00 ` Klaus Alexander Seistrup
2018-09-24 10:22 ` Peter Stephenson
2018-09-24 12:29 ` Klaus Alexander Seistrup
2018-09-24 12:51 ` Peter Stephenson
2018-09-24 13:22 ` [PATCH] zshbuiltins(1): Document 'which''s "not found is not an error" behaviour Daniel Shahaf
2018-09-24 22:18 ` BUG: Shell builtin `which` prints non-existent commands to stdout Stephane Chazelas
2018-09-25 7:56 ` Stephane Chazelas
2018-09-24 22:32 ` Stephane Chazelas [this message]
2018-09-25 9:10 ` Peter Stephenson
[not found] ` <20180924112218.7bac7f2c@camnpupstephen.cam.scsc.local>
2018-09-24 10:25 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180924223253.j46bxsughzy6grbf@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=p.stephenson@samsung.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).