From 8a5c836b51ce29fb22e0692c03fbc1e405c6522f Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 1 Aug 2023 14:00:48 -0400 Subject: [PATCH] man: fix `man -K` search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ć 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(-) diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 4fd6f886e87..c95b47e2ee6 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -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