From nobody@FreeBSD.org  Sat Mar  9 15:21:05 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 8B3FF37B402
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  9 Mar 2002 15:21:05 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g29NL5Z90855;
	Sat, 9 Mar 2002 15:21:05 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200203092321.g29NL5Z90855@freefall.freebsd.org>
Date: Sat, 9 Mar 2002 15:21:05 -0800 (PST)
From: wolfram schneider <wosch@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: which(1)  returns wrong exit status for multiple arguments
X-Send-Pr-Version: www-1.0

>Number:         35717
>Category:       bin
>Synopsis:       which(1)  returns wrong exit status for multiple arguments
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 09 15:30:00 PST 2002
>Closed-Date:    Fri Jul 30 11:34:08 UTC 2010
>Last-Modified:  Fri Jul 30 11:34:08 UTC 2010
>Originator:     wolfram schneider
>Release:        
>Organization:
>Environment:
>Description:
      The new c version of which(1) command returns wrong exit 
status for multiple arguments.

$ which foobar cat
/bin/cat
$ echo $?
1

which should  returns  true  if  any  of the arguments are found,
false if none are found.

>How-To-Repeat:
      
>Fix:
      
>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@ringlet.net>
To: wolfram schneider <wosch@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/35717: which(1)  returns wrong exit status for multiple arguments
Date: Sun, 10 Mar 2002 16:41:14 +0200

 On Sat, Mar 09, 2002 at 03:21:05PM -0800, wolfram schneider wrote:
 > 
 > >Number:         35717
 > >Category:       bin
 > >Synopsis:       which(1)  returns wrong exit status for multiple arguments
 > >Originator:     wolfram schneider
 > >Description:
 >       The new c version of which(1) command returns wrong exit 
 > status for multiple arguments.
 > 
 > $ which foobar cat
 > /bin/cat
 > $ echo $?
 > 1
 > 
 > which should  returns  true  if  any  of the arguments are found,
 > false if none are found.
 
 FWIW, this is consistent with the 'which' built-in command of csh, tcsh
 and zsh.  Bash's 'type' built-in, though, returns 0 in this case, exactly
 as the Perl version of which(1) in RELENG_4 does.  I do not know how this
 is with other shells; are there any standards on the return value
 of which(1)?
 
 G'luck,
 Peter
 
 -- 
 Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 I had to translate this sentence into English because I could not read the original Sanskrit.

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, wosch@FreeBSD.org
Cc:  
Subject: Re: bin/35717: which(1) returns wrong exit status for multiple
 arguments
Date: Fri, 30 Jul 2010 00:30:20 +0200

 > [5.x's /usr/bin/which returns 1 if any argument is not found, instead
 > of only when all arguments are not found like 4.x's]
 
 The new behaviour seems consistent with what most other utilities do (if
 an error occurs processing an argument, processing continues with the
 next argument but the exit status will be non-zero). POSIX mentions this
 in "Consequences of Errors" in XCU 1.4 Utility Description Defaults.
 Following this for non-standard utilities is not a requirement but makes
 things more consistent.
 
 There is no standard for which(1). The closest is probably the tcsh(1)
 builtin which behaves like the new /usr/bin/which.
 
 There seems little reason to change.
 
 -- 
 Jilles Tjoelker
State-Changed-From-To: open->closed 
State-Changed-By: wosch 
State-Changed-When: Fri Jul 30 11:33:44 UTC 2010 
State-Changed-Why:  
The new behaviour seems consistent with what most other utilities do 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35717 
>Unformatted:
