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 43538
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: BUG: Shell builtin `which` prints non-existent commands to stdout
- Date: Mon, 24 Sep 2018 23:32:53 +0100
- Cc: Zsh Workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=olZrR0emFw93SZxllalisnQmW/8c8lHTTHnYy9BQ9zk=; b=aiDsK2I3WPVxlhrYJhyuW5fAMIzNl6s2MTP6tzdHOx31GIKauvvU9gE4ntQZkhUmjJ fB5KKrKpOjemQ/cQJmWY4fnRVl9fcz8ikX8xIj4OBmXdw2eTWXYmNfdvKq+k6uxT1Bac eS578jV8XaGko06PIWRdwtWkyzgVo7Maf/HPs53qwNJrbjKi7nUrPGivFTyz0CQofajS bk8LXLCQpfF4735g1WKYkjQjwsLtCKQF2xTUKbqZ1SBUK6ytUvfZ4lhpiisdjouUaugy KOO1eHyFI9RtMKmmaij6dJFLNULbuP84151rVf2FSGK0tALDbES8lZ6M8nQmKW+GamzE 8u5Q==
- In-reply-to: <20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae~XVwcoX7b91518615186eucas1p2T@eucas1p2.samsung.com>
- 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>
- Mail-followup-to: Peter Stephenson <p.stephenson@xxxxxxxxxxx>, Zsh Workers <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180924080113epcas4p4f8f89aa03a2cebc5030fd45dca0f6e84@epcas4p4.samsung.com> <20180924080031.ee7lqmthxpmvqaal@klaus.seistrup.dk> <20180924102219eucas1p2469f827265423a2f3b5e7d98fc08412e~XTuQ1aIyy2293622936eucas1p2L@eucas1p2.samsung.com> <20180924122933.gpzp4vfix6zl66nw@klaus.seistrup.dk> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author