Bug 223522 - `whatis .’ returns random results
Summary: `whatis .’ returns random results
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-08 10:47 UTC by Wolfram Schneider
Modified: 2022-03-16 21:22 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfram Schneider freebsd_committer freebsd_triage 2017-11-08 10:47:52 UTC
Running whatis for the single character “a” works fine:

$ whatis a
a.out(5) - format of executable binary files

But running whatis with a single dot returns random results. It includes “a.out”, but many manpages which don’t have a ‘.’ in the name

$ whatis  . | head -8
whatis .|head -8
c++filt(1) - decode C++ symbols
w(1) - display who is logged in and what they are doing
config.guess-2.69(1) - guess the build system triplet
config.sub-2.69(1) - validate and canonicalize a configuration triplet
ifnames-2.69(1) - Extract CPP conditionals from a set of files
a.out(5) - format of executable binary files
rtld, ld-elf.so.1, ld.so(1) - run-time link-editor
gittutorial-2(7) - A tutorial introduction to Git: part two
Comment 1 Piotr Pawel Stefaniak freebsd_committer freebsd_triage 2021-10-03 19:21:58 UTC
I think it works as intended. As per apropos.1, expressions here are regular expressions as described in re_format.7.

So your dot matches any character.
Comment 2 Piotr Pawel Stefaniak freebsd_committer freebsd_triage 2021-10-03 19:29:38 UTC
After reading PR223524 I think your expectation is that whatis will not use a regexp since whatis is an alias for apropos -f, and -f is: "Search for all words in expression in manual page names only.".

I don't think the manual page is clear on what happens and on top of that I'm not sure what should actually happen.
Comment 3 Wolfram Schneider freebsd_committer freebsd_triage 2021-10-04 07:47:38 UTC
The problems still exists in FreeBSD-14-current. Calling whatis with the a dot (".") as argument returns 48 hits, but only 24 contains a dot.


$ whatis .  | wc -l
      48

$ whatis . | egrep '\.' | wc -l
      24

On debian11 I get:
$ whatis .
.: nothing appropriate.


and on centos8
$ whatis .
. (1)                - bash built-in commands, see bash(1)
Comment 4 Dakotah Lambert 2021-12-31 07:46:00 UTC
apropos (and by extension whatis) uses (case-insensitive, extended) regular expressions in all instances. In all reported instances, the “.” has matched a “word” containing a single character, as confirmed by

    $ printf '%s\n' word-to-test | grep -o '\<.\>'

The results are as follows:

    c  c++filt
    w  w
    2  config.guess-2.69
    2  config.sub-2.69
    2  ifname-2.69
    a  a.out
    1  ld-elf.so.1
    2  gittutorial-2

Note also:

    $ whatis '[a]'
    a.out(5) - format of executable binary files

In order to search for a manpage entitled “.” alone, you would search

    $ whatis '[.]'
    whatis: nothing appropriate

To confirm:

    $ whatis . | wc -l
    17
    $ whatis . | grep '\<.\>' | wc -l
    17