From nobody@FreeBSD.org  Fri Dec 30 18:12:13 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 752DF16A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 30 Dec 2005 18:12:13 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 07D5543D46
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 30 Dec 2005 18:12:13 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jBUICC7Z050032
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 30 Dec 2005 18:12:12 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id jBUICClL050031;
	Fri, 30 Dec 2005 18:12:12 GMT
	(envelope-from nobody)
Message-Id: <200512301812.jBUICClL050031@www.freebsd.org>
Date: Fri, 30 Dec 2005 18:12:12 GMT
From: Sokolov Alexey <sokolhacker@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: update: /usr/src/usr.bin/whereis/whereis.c
X-Send-Pr-Version: www-2.3

>Number:         91101
>Category:       bin
>Synopsis:       [patch] whereis(1): make more readable
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    edwin
>State:          feedback
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 30 18:20:03 GMT 2005
>Closed-Date:    
>Last-Modified:  Thu Nov 10 15:14:16 UTC 2011
>Originator:     Sokolov Alexey
>Release:        6.0-STABLE
>Organization:
SokolSoft.org.ru
>Environment:
>Description:
The conclusion of a command whereis is not pleasant to me. 
Here an example: 

%whereis 
vim vim:/usr/local/bin/vim/usr/local/man/man1/vim.1.gz/usr/ports/editors/vim 

Well it is not readable! And if the file does not exist, in general
messages on a mistake is not printed:

%whereis vim_

Has decided to modify a part of a source code
(/usr/src/usr.bin/whereis/whereis.c):

/*begin*/
                if (!opt_q) {
                        /* printf("%s:", name); */
                                printed++;
                        printf ("%s:", name);
                }
                if (bin) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(bin, stdout); */
                        printf ("\n %s", bin);
                }
                if (man) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(man, stdout); */
                        printf ("\n %s", man);
                }
                if (src) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(src, stdout); */
                        printf ("\n %s\n", src);
                }
                if (!printed)
                        putchar('\n');
                /* If files have not been found */
                if ((!bin) && (!man) && (!src))
                        printf (" not found!\n");
/*end*/

Now all is much more pleasant:

%whereis vim
vim:
 /usr/local/bin/vim
 /usr/local/man/man1/vim.1.gz
 /usr/ports/editors/vim

And in case of a mistake:

%whereis vim_
vim_: not found!
>How-To-Repeat:

>Fix:
                if (!opt_q) {
                        /* printf("%s:", name); */
                                printed++;
                        printf ("%s:", name);
                }
                if (bin) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(bin, stdout); */
                        printf ("\n %s", bin);
                }
                if (man) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(man, stdout); */
                        printf ("\n %s", man);
                }
                if (src) {
                        /* if (printed++)
                                putchar(' ');
                        fputs(src, stdout); */
                        printf ("\n %s\n", src);
                }
                if (!printed)
                        putchar('\n');
                /* If files have not been found */
                if ((!bin) && (!man) && (!src))
                        printf (" not found!\n");
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->edwin 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Tue Aug 12 23:45:47 UTC 2008 
Responsible-Changed-Why:  
I'll see if I can do something with it. 

It most likely will be, to not break current implementations, an 
option called -h (human readable) which will use the output you 
proposed. 



http://www.freebsd.org/cgi/query-pr.cgi?pr=91101 
State-Changed-From-To: open->feedback 
State-Changed-By: arundel 
State-Changed-When: Thu Nov 10 15:05:51 UTC 2011 
State-Changed-Why:  
Can this PR be closed? 

'whereis vim' reports: 
'vim: /usr/local/bin/vim /usr/local/man/man1/vim.1.gz /usr/ports/editors/vim', 
which imo is very well readable. Also whereis is a re-implementation of the 
historic whereis utility (see whereis(1) man page) and thus the output, when 
no matches are found, cannot be changed. the suggested '%s: not found!' would 
therefor break historic behaviour and thus scripts which rely on this behavior. 

Alex 

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