From nobody@FreeBSD.org  Tue Jan 26 18:21:05 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 870D510656A4
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jan 2010 18:21:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 764FF8FC26
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jan 2010 18:21:05 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0QIL5Ji056538
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 26 Jan 2010 18:21:05 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0QIL57r056537;
	Tue, 26 Jan 2010 18:21:05 GMT
	(envelope-from nobody)
Message-Id: <201001261821.o0QIL57r056537@www.freebsd.org>
Date: Tue, 26 Jan 2010 18:21:05 GMT
From: Jan Schaumann <jschauma@netmeister.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: whatis(1) should print error message to stderr
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         143271
>Category:       gnu
>Synopsis:       [patch] whatis(1) should print error message to stderr
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gordon
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 26 18:30:07 UTC 2010
>Closed-Date:    Mon Oct 04 08:44:32 PDT 2010
>Last-Modified:  Mon Oct 04 08:44:32 PDT 2010
>Originator:     Jan Schaumann
>Release:        
>Organization:
>Environment:
>Description:
If you run 'whatis oink', it will print 'oink: nothing appropriate' to stdout.  This is an error message and should go to stderr.
>How-To-Repeat:
whatis oink
>Fix:
--- /tmp/whatis 2010-01-26 18:20:15.000000000 +0000
+++ /usr/bin/whatis     2009-07-08 19:28:03.000000000 +0000
@@ -102,7 +102,7 @@
 
        # nothing found, exit
        if [ -z "$line" -a ! -z "$line2" ]; then
-               printf -- "$line2" >&2
+               printf -- "$line2"
                exit $exit_nomatch
        else
                ( printf -- "$line2"; echo "$line"; cat ) | $PAGER


>Release-Note:
>Audit-Trail:

From: Jan Schaumann <jschauma@netmeister.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: misc/143271: whatis(1) should print error message to stderr
Date: Tue, 26 Jan 2010 13:40:07 -0500

 --BXVAT5kNtrzKuDFl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Additionally, whatis(1) returns 0 if nothing appropriate was found.  It
 should return 1.  Apparently that would confuse 'man -k', so one way to
 do this would be:
 
 # man -k complains if exit_nomatch=1 and no keyword matched
 if expr "${0}" : ".*whatis" >/dev/null 2>&1 ; then
         exit_nomatch=1
 else
         exit_nomatch=0
 fi
 exit_error=2
 
 
 
 --BXVAT5kNtrzKuDFl
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (NetBSD)
 
 iD8DBQFLXzcHfFtkr68iakwRAorHAJ0Zxlyr0Sl6nG3Osh5X6Yy+Cm5CsACfV2Du
 biRzb+acUfuw0PFbGkCYbQw=
 =TjD6
 -----END PGP SIGNATURE-----
 
 --BXVAT5kNtrzKuDFl--

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc: Jan Schaumann <jschauma@netmeister.org>
Subject: Re: bin/143271: [patch] whatis(1) should print error message to stderr
Date: Sun, 1 Aug 2010 21:33:48 +0000

 i agree with the stdout/sterr issue.
 
 however i don't see why whatis'es return values should be altered. it's common practice to return 0 on success. so returning 0 if whatis recognizes the keyword is just fine.
 
 cheers.
 alex
 
 -- 
 a13x

From: Jan Schaumann <jschauma@netmeister.org>
To: Alexander Best <arundel@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/143271: [patch] whatis(1) should print error message to
	stderr
Date: Sun, 1 Aug 2010 18:30:28 -0400

 --6v9BRtpmy+umdQlo
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Alexander Best <arundel@freebsd.org> wrote:
 =20
 > however i don't see why whatis'es return values should be altered.
 > it's common practice to return 0 on success. so returning 0 if whatis
 > recognizes the keyword is just fine.
 
 The problem is that whatis(1) returns 0 even if it does NOT find
 anything, which should be an error condition.
 
 $ whatis oink
 oink: nothing appropriate
 $ echo $?
 0
 $=20
 
 -Jan
 
 --6v9BRtpmy+umdQlo
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.9 (NetBSD)
 
 iD8DBQFMVfWEfFtkr68iakwRAgevAJ9afa0p/R2OZrPli98fUhtCyY771gCeL437
 K2ujeDIlfMO6VOpUvN85N9s=
 =4bQX
 -----END PGP SIGNATURE-----
 
 --6v9BRtpmy+umdQlo--

From: Alexander Best <arundel@freebsd.org>
To: Jan Schaumann <jschauma@netmeister.org>
Cc: bug-followup@freebsd.org
Subject: Re: bin/143271: [patch] whatis(1) should print error message to stderr
Date: Sun, 1 Aug 2010 22:39:53 +0000

 On Sun Aug  1 10, Jan Schaumann wrote:
 > Alexander Best <arundel@freebsd.org> wrote:
 >  
 > > however i don't see why whatis'es return values should be altered.
 > > it's common practice to return 0 on success. so returning 0 if whatis
 > > recognizes the keyword is just fine.
 
 oh i'm sorry. i think this was a misunderstanding then. indeed this is a bug. although the whatis(1) manual only talks about the return status of apropos i also checked apropos and it also returns 0 if nothing was found.
 
 so this is just plain wrong and apropos/whatis don't do what they're supposed to according to the manual.
 
 cheers.
 alex
 
 > 
 > The problem is that whatis(1) returns 0 even if it does NOT find
 > anything, which should be an error condition.
 > 
 > $ whatis oink
 > oink: nothing appropriate
 > $ echo $?
 > 0
 > $ 
 > 
 > -Jan
 
 
 
 -- 
 a13x
Responsible-Changed-From-To: freebsd-bugs->gordon 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Fri Aug 6 20:28:27 UTC 2010 
Responsible-Changed-Why:  

Assigning to Gordon since he is doing work in this area. 

The patch is reversed, but looks right as far as it goes. The 
value of $exit_nomatch should also be reviewed, the audit trail 
is likely correct that it should be non-zero. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143271 

From: Gordon Tetlow <gordon@freebsd.org>
To: bug-followup@FreeBSD.org, jschauma@netmeister.org
Cc:  
Subject: Re: gnu/143271: [patch] whatis(1) should print error message to stderr
Date: Mon, 16 Aug 2010 10:06:13 -0700

 Looking at this a bit more, the problem with just blindly dumping the
 "nothing appropriate" out to stderr is if the user queries multiple keywords
 "apropos oink ls". When the pager gets invoked, the stderr is going to be
 squashed by the pager resulting in the user most likely missing the "oink:
 nothing appropriate".
 
 I have incorporated a fix for this bug in a replacement version of man that
 I'm working on. Essentially, the user will get all of the pager output and
 then display the stderr messages at the end.
 
 As for the exit code, there is a comment in the script about how man -k
 complains if the exit code is not 0. I haven't look deeper than that just
 yet, but as this version of man/manpath/whatis/apropos is slated to be axed,
 it may not be worth the time and effort to fix.
 
 Thanks,
 Gordon
State-Changed-From-To: open->analyzed 
State-Changed-By: gordon 
State-Changed-When: Mon Aug 30 10:52:44 PDT 2010 
State-Changed-Why:  
Solution has been integrated to my WIP. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143271 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: gnu/143271: commit references a PR
Date: Fri,  1 Oct 2010 03:59:25 +0000 (UTC)

 Author: gordon
 Date: Fri Oct  1 03:59:18 2010
 New Revision: 213317
 URL: http://svn.freebsd.org/changeset/base/213317
 
 Log:
   Implementaiton of man, manpath, whatis, and apropos written entirely in sh.
   
   Features of this new version in favor of the old one:
   BSD licensed -- old one is GPL.
   Imports configuration from /etc/man.conf and LOCALBASE/etc/man.d/*.conf
   allowing ports to extend the base functionality. The pluggable
   configuration can supplement the manual search path (retiring use.perl),
   add locales, and override language specific toolsets (attempt to merge
   the japanese/man port into the base system as much as possible).
   
   Much effort has been made to make this version mirror the functionality
   of the existing implementation. For 99% of users, it should be a drop in
   replacement.
   
   PR:		gnu/143271, gnu/4419
   Reviewed by:	dougb (previous versions)
   Approved by:	wes (mentor)
 
 Added:
   head/usr.bin/man/
   head/usr.bin/man/Makefile   (contents, props changed)
   head/usr.bin/man/apropos.1   (contents, props changed)
   head/usr.bin/man/man.1   (contents, props changed)
   head/usr.bin/man/man.conf.5   (contents, props changed)
   head/usr.bin/man/man.sh   (contents, props changed)
   head/usr.bin/man/manpath.1   (contents, props changed)
 
State-Changed-From-To: analyzed->patched 
State-Changed-By: gordon 
State-Changed-When: Thu Sep 30 21:29:12 PDT 2010 
State-Changed-Why:  
New code has been integrated that should take care of this problem in 
9-CURRENT. Once I have hooked it up to the build, I will close the case. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=143271 
State-Changed-From-To: patched->closed 
State-Changed-By: gordon 
State-Changed-When: Mon Oct 4 08:42:46 PDT 2010 
State-Changed-Why:  
Confirmed solution: 

# whatis oink 2> /dev/null 
# whatis oink 
oink: nothing appropriate 

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