From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43538-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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,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 67dbc2e2 for ; Mon, 24 Sep 2018 22:33:11 +0000 (UTC) Received: (qmail 17304 invoked by alias); 24 Sep 2018 22:33:00 -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: 43538 Received: (qmail 28067 invoked by uid 1010); 24 Sep 2018 22:33:00 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm1-f66.google.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(209.85.128.66):SA:0(-1.9/5.0):. Processed in 1.589621 secs); 24 Sep 2018 22:33:00 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=olZrR0emFw93SZxllalisnQmW/8c8lHTTHnYy9BQ9zk=; b=NdAFrvGuu7IFxJKMLLfqRkRf3wsOccNfDt7kQ79NgC3tJNXU0PmqDo9RaRR7Nun2+6 ZFumDWBkr/2x6P+ml+JZVwmroqx2Z0AeNHe2pKsnqQcAuDPzh21GBAP/rb29bAvvi2vN FjY0yaUPJdmXYh/0BNPHz8BQcBqM4Uv593ZyoSAPjjEB9wORXv81eOee4Jyjabn51JrR rFV+el6naCzDAQAF7bWJyoUbz+4OjDoCtCP7KZ9s3AzUCUAAVsQQTWRdHy2JgermWsgn aiupTcr15eyRoLThuc3K3D4PxjdEUz9p+a+vYpB2g+TlqNoiPUqaRrgf3DUPXr+892+S nOZg== X-Gm-Message-State: ABuFfoim1sW4SqDP+81XB89ZgpvnDISicsoPU/xGkYOILzPZqC2mYgH0 4k2es5VPTw0XQTy39Q9F+YuuszFmr1Q= X-Google-Smtp-Source: ACcGV63FTIfEsxZLG6sGs+n8spMj+ftg2j2jsX/nrOc/QcIuGrCs9skSD/bzySrlISscA43aXjNGtw== X-Received: by 2002:a1c:2d54:: with SMTP id t81-v6mr282541wmt.31.1537828375020; Mon, 24 Sep 2018 15:32:55 -0700 (PDT) Date: Mon, 24 Sep 2018 23:32:53 +0100 From: Stephane Chazelas To: Peter Stephenson Cc: Zsh Workers Subject: Re: BUG: Shell builtin `which` prints non-existent commands to stdout Message-ID: <20180924223253.j46bxsughzy6grbf@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , Zsh Workers References: <20180924080031.ee7lqmthxpmvqaal@klaus.seistrup.dk> <20180924102219eucas1p2469f827265423a2f3b5e7d98fc08412e~XTuQ1aIyy2293622936eucas1p2L@eucas1p2.samsung.com> <20180924122933.gpzp4vfix6zl66nw@klaus.seistrup.dk> <20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae~XVwcoX7b91518615186eucas1p2T@eucas1p2.samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180924125126eucas1p2e4ae5b63ce6320957ee99737f93181ae~XVwcoX7b91518615186eucas1p2T@eucas1p2.samsung.com> User-Agent: NeoMutt/20171215 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