When searching man page with `man -K` I need to escape space character with `\s`. I looked into ma, egrep and re_format man page, this format is not documented anywhere. extract from `man man`: -K regexp Does a full text search in all manual pages. regexp is a regular expression as understood by “grep -E”. This option requires mandoc(1). This is a slow operation. `man grep`: -E, --extended-regexp Interpret pattern as an extended regular expression (i.e., force grep to behave as egrep). `man re_format`: a ‘\’ followed by one of the characters ‘^.[$()|*+?{\’ (matching that character taken as an ordinary character), a ‘\’ followed by any other character‡ (matching that character taken as an ordinary character, as if the ‘\’ had not been present‡), I think the issue comes from the egrep regex format. But I have found nothing into its documentation.
Created attachment 243625 [details] quote the regexp argument This rather seems to be a problem with quoting the regexp argument. We should also just quit after processing -K option (according to synopsis).
To be totally clear. I think there are 2 issues here: 1. The behavior of -K regex. This does work: man -K "BIOS\sextension" this doesn't: man -K "BIOS extension" 2. the fact that '\s' is not documented in man page and contradict re_format man page.
(In reply to Yuri Pankov from comment #1) The only part needed should be: grep -E ${gflags} "${manfile}" -e "${re}" Spaces are preserved in variable assignment, e.g. in re=${1} Proposed change in https://reviews.freebsd.org/D41282
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=8a5c836b51ce29fb22e0692c03fbc1e405c6522f commit 8a5c836b51ce29fb22e0692c03fbc1e405c6522f Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2023-08-01 18:00:48 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2023-08-02 20:46:57 +0000 man: fix `man -K` search Quote re arg to grep in case it has spaces, and quote [:blank:] tr arg to avoid the shell interpreting []. PR: 272729 Reviewed by: Mina Galić <freebsd@igalic.co> Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41282 usr.bin/man/man.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
^Triage: assign to committer and ask if possible interest in MFC.
^Triage: close due to lack of interest in MFC.