Bug 223556 - apropos(1) should use regular expression by default for a keyword search
Summary: apropos(1) should use regular expression by default for a keyword search
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Yuri Pankov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-09 10:46 UTC by Wolfram Schneider
Modified: 2021-10-04 08:17 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 2017-11-09 10:46:14 UTC
apropos does a keyword search. In the past the keyword was a regular expression

On FreeBSD 10 you can run:

# search for 'f.*bar' 
$ apropos 'f.*bar' | wc -l
       4

# or dump the database
apropos '.' | wc -l
    5582


On FreeBSD12-current

$ apropos 'f.*bar' | wc -l
apropos: nothing appropriate
       0

$ apropos '.' | wc -l
     318

To use regular expression, you need to prefix the tilde now:

$ apropos '~f.*bar' | wc -l
       2
apropos '~.' | wc -l
    4488


I do not like this change. We are incompatible with anything before in FreeBSD, and we are incompatible with the gnu tools on debian/ubuntu/centos.
Comment 1 Piotr Pawel Stefaniak freebsd_committer 2021-10-03 19:43:30 UTC
This may be no longer true. I get the same number of results for both '.' and '~.' (9072).
Comment 2 Wolfram Schneider freebsd_committer 2021-10-04 08:17:06 UTC
(In reply to Piotr Pawel Stefaniak from comment #1)

I get the same number of results for both '.' and '~.' too now.
$ apropos '.'|wc -l
    9517
$ apropos '~.'|wc -l
    9517

However, the result number on FreeBSD 14.0-CURRENT are still weird.

# case sensitive regex
$ apropos '~f.*bar' | wc -l
       4

# case insensitive regex
$ apropos 'f.*bar' | wc -l                 
       5 

# regex by grep
$ apropos . | grep 'f.*bar' | wc -l
       7
$ apropos . | grep -i 'f.*bar' | wc -l
       8

On centos8 it looks better:
$ apropos 'f.*bar' | wc -l
10
$ apropos . | egrep -i 'f.*bar'  |wc -l
10