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
This commit is contained in:
Ed Maste 2023-08-01 14:00:48 -04:00
parent 0c783a37d5
commit 8a5c836b51

View File

@ -1000,11 +1000,11 @@ do_full_search() {
gflags="${gflags} --label"
set +f
for mpath in $(echo "${MANPATH}" | tr : [:blank:]); do
for section in $(echo "${MANSECT}" | tr : [:blank:]); do
for mpath in $(echo "${MANPATH}" | tr : '[:blank:]'); do
for section in $(echo "${MANSECT}" | tr : '[:blank:]'); do
for manfile in ${mpath}/man${section}/*.${section}*; do
mandoc "${manfile}" 2>/dev/null |
grep -E ${gflags} "${manfile}" -e ${re}
grep -E ${gflags} "${manfile}" -e "${re}"
done
done
done