Bug 223556

Summary: apropos(1) should use regular expression by default for a keyword search
Product: Base System Reporter: Wolfram Schneider <wosch>
Component: binAssignee: Yuri Pankov <yuripv>
Status: In Progress ---    
Severity: Affects Only Me CC: emaste, pstef, yuripv
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Wolfram Schneider freebsd_committer freebsd_triage 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 freebsd_triage 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 freebsd_triage 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