Bug 91101 - [patch] whereis(1): make more readable
Summary: [patch] whereis(1): make more readable
Status: Closed Feedback Timeout
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 6.0-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-30 18:20 UTC by Sokolov Alexey
Modified: 2018-02-18 07:23 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sokolov Alexey 2005-12-30 18:20:03 UTC
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!

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");
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2008-08-13 00:45:47 UTC
Responsible Changed
From-To: freebsd-bugs->edwin

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.
Comment 2 Alexander Best freebsd_committer freebsd_triage 2011-11-10 15:05:51 UTC
State Changed
From-To: open->feedback

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
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:34 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped