From nobody Sat Jan 20 08:55:16 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TH9Kx01zYz56cGR; Sat, 20 Jan 2024 08:55:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TH9Kw6WnZz4JCC; Sat, 20 Jan 2024 08:55:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705740916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pGzYe7pOXTXxNmXbnOsvdjt+SrRWchMpVyUuQGmslV4=; b=oKpMq6yJdu9dBuuIxUsyRfJuvgVdOlUH3FpFTeOc/C5pzICRi1v/Y1rUhu2qRsy4KJ4O8n 6zVkufzoa+/DbWY8fcd3rZocBdajOLqfJ6RQERI05yww5+ZfuLpFDREcxKRDbEb1htsUio gOMn/n1WAbC138ED1cqzQ1SKdlIK7T1jac0RvyWwkEE8UPwNQgS+eDP5/faBudGvgNEAb6 1Vfo09KjbGqIMQEOjUPvkdYM9R4qMqcusi6dDXIh9LArvfcSL/1vE4rKJD2B3+XJRIDoDA 8bq06liTJ3uCFMScHDH7w2GjsT9duJ0LdJnsWxL8AxvgRXK88C5czUdRvNVcEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705740916; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pGzYe7pOXTXxNmXbnOsvdjt+SrRWchMpVyUuQGmslV4=; b=RowGHZKSck2bCUXHGLuKJzVuPdPVrFnT9lUr7DmdhQmETYAHaX6jOSFnZij5ypjFLdnoqF b/UTr3u7UFHDFgzJEc/FlRvHZaOBL3SHzCWC01ClQzMsaDVo4CLKtBvPnu2HQmI5LQHYMV 5X0CHR3oDNQjM0X8Ya5HRa07RBtdfQeiuh7y6x0q11UBkGnhoOafAXt00NkSAbC8Dxzt9O +NdQhVpup3SehKnuBUCur+USvHJRRmQ7lIZ3iJTvv6SOiPEfCclNnlAueh219cJ+SdYTFv F1GoW6WmnrETDYrjkH3cJK45W/bpgcgV7aRWyxgXrKpyBu5TCugutzfkohd43g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705740916; a=rsa-sha256; cv=none; b=fCbBQT2CX4Gg3RvrwnduIGsk5t6v3rfWz5KOH+dXyufT9dQlkQ5HPs3lLT+rRfC7EXqHBf n1Kr1UBu6lDsEooH1+Ci13flDiL5NW/QMARzwImIC4GMKLSYe4V6oVuexRo5Pt++rUomu0 MJSRLfRBwQtnypvn2kizP4R1Z8AozNSARy2fdlHv7fhcOk8RsYcejELMr2783ouavyD2Ej NOx2V132Py/jRB5lL1y/SQECoMoY2ymeNbhBKvYVp33XfX80Yx6KXPqoqkFdpntCAw0yzg Zbf5IPNGPH72comkEXsHDQ0Xrwy4/fZ8jos1hzgalYuvr78GzbyFAeXEXDOzyQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TH9Kw5ZZ5zSlh; Sat, 20 Jan 2024 08:55:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40K8tGjk078743; Sat, 20 Jan 2024 08:55:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40K8tGuT078740; Sat, 20 Jan 2024 08:55:16 GMT (envelope-from git) Date: Sat, 20 Jan 2024 08:55:16 GMT Message-Id: <202401200855.40K8tGuT078740@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Wolfram Schneider Subject: git: 7169c947ab41 - stable/14 - man(1): support spaces in filenames List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wosch X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 7169c947ab4150a539f2af6c9dcf3ab4344b0033 Auto-Submitted: auto-generated The branch stable/14 has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=7169c947ab4150a539f2af6c9dcf3ab4344b0033 commit 7169c947ab4150a539f2af6c9dcf3ab4344b0033 Author: Wolfram Schneider AuthorDate: 2024-01-13 16:16:55 +0000 Commit: Wolfram Schneider CommitDate: 2024-01-20 08:51:12 +0000 man(1): support spaces in filenames The globbing function in exists() needs to handle white spaces. PR: 275978 Reviewed by: kevans, bapt, emaste Differential Revision: https://reviews.freebsd.org/D43222 MFC after: 1 week (cherry picked from commit e3c7b76fa8105929ae9a785e5ffc44274b1b0a81) --- usr.bin/man/man.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 7e2151295ba7..777726f880db 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -191,7 +191,9 @@ decho() { } # Usage: exists glob -# Returns true if glob resolves to a real file. +# +# Returns true if glob resolves to a real file and store the first +# found filename in the variable $found exists() { local IFS @@ -201,14 +203,16 @@ exists() { # Use some globbing tricks in the shell to determine if a file # exists or not. set +f - set -- "$1" $1 + for file in "$1"* + do + if [ -r "$file" ]; then + found="$file" + set -f + return 0 + fi + done set -f - if [ "$1" != "$2" -a -r "$2" ]; then - found="$2" - return 0 - fi - return 1 } @@ -230,10 +234,10 @@ find_file() { fi decho " Searching directory $manroot" 2 - mann="$manroot/$4.$2*" - man0="$manroot/$4.0*" - catn="$catroot/$4.$2*" - cat0="$catroot/$4.0*" + mann="$manroot/$4.$2" + man0="$manroot/$4.0" + catn="$catroot/$4.$2" + cat0="$catroot/$4.0" # This is the behavior as seen by the original man utility. # Let's not change that which doesn't seem broken. @@ -313,7 +317,7 @@ man_check_for_so() { .so*) trim "${line#.so}" decho "$manpage includes $tstr" # Glob and check for the file. - if ! check_man "$path/$tstr*" ""; then + if ! check_man "$path/$tstr" ""; then decho " Unable to find $tstr" return 1 fi