From nobody Mon Feb 12 15:49:38 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 4TYTRQ6Qspz5B35J; Mon, 12 Feb 2024 15:49:38 +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 4TYTRQ3yc4z43kD; Mon, 12 Feb 2024 15:49:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707752978; 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=O7UbtwYGKzcdUEClLPdcgZMIam1JQoQ55WHEuwLZH4k=; b=BXI3fp2lcjk6WSo+1P/26PdrmV9TYfEtME9eRVuvaAQjyhDY1/Qc0/tVLuB0kKADuLm3uc PxjfeYqnwnK3KHS5YrkodB7naEGg//eXmNily84slQzEFtFGif6IQWfMtmDslCggrTdBlv HCcwYr/p3dcoVYe0eHO50Ut2l8a284DVmrgNIgx7MCj9HOrgzFrMbBQ+q2IzWMQe/TdzB3 TQMd27mzsg6hm4ZPZxUsrQI2MjjTSYZLxmjHc6dSgTnjf4uOfUQIVR195WPqAf1li3fQ0R z5nNqrmazFIJ3Orv+cktBZeSDIzhaTbbE65iXMXqasA2uvJnpOdcAOzG3Hkm3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707752978; a=rsa-sha256; cv=none; b=iUtgu8NrqstwTliXH2wU2mRxmGBFwMSITSBW6lqm+BD3plVYRjAESLDxfYpycQDsNa8Viz 0Qk1RghVXKpdhpkkZCST3oBl6Kj4eFn/HQdApmvpXphbvYW7H90hcrDv+nwWl7UFY5ObOD /2NSHBJOkhArSJY8GXy893Vjdn7WeACXL0UHoNsEMGKRh1alUtB/XFcvmJMkmZy1lsm3zK mLG7GU4O0NK+cD1889B0RAk/G8AIwrbe0j5yQoS5AQR5mweedqsvgc3OHxGie0jjSwnprB MmT87+5KdUeG2FfB2R6e3/RJJHcfKf/0IBVpCp7fPAjRZxq9zvPQuOAxZuKsDA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707752978; 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=O7UbtwYGKzcdUEClLPdcgZMIam1JQoQ55WHEuwLZH4k=; b=CbhVXFmIdXdpfzoC53eF+ZIVNNL7g04PhZie9r2lqD9wHHTRAwIcnRkKWvWk2uI9DiqAwz hwz17ZvKyLoQQB/8AkI2I18EFKOM+S/dHvI1KA4yJX/olTkeYkVssf2wzGpNsr05VWAY4h WdbYljEgFsgczBLbD99zfOp4tMDXlJnbauMrC6l1w2xOHCMJz9o8E6EmRYFJ2VAEH6AD+k Yq7hIVN6mPGiO8v45WjdjUYH8LPEG0uVjRt/ogpw+cvPvEjpAYsUxN9CQQGswBH5JLbrkL mN8e6uEOBmf2KUH98pjRPlWgFySKUoQK/q3Q/WeRQQiulbghpaWCHV+dI23BBg== 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 4TYTRQ2nrTzYBh; Mon, 12 Feb 2024 15:49:38 +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 41CFnch4010183; Mon, 12 Feb 2024 15:49:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CFncrj010180; Mon, 12 Feb 2024 15:49:38 GMT (envelope-from git) Date: Mon, 12 Feb 2024 15:49:38 GMT Message-Id: <202402121549.41CFncrj010180@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: 1024a7c061ed - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 1024a7c061ed5cb34f5f3730f70432b5c01c9a12 Auto-Submitted: auto-generated The branch stable/13 has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=1024a7c061ed5cb34f5f3730f70432b5c01c9a12 commit 1024a7c061ed5cb34f5f3730f70432b5c01c9a12 Author: Wolfram Schneider AuthorDate: 2024-01-13 16:16:55 +0000 Commit: Wolfram Schneider CommitDate: 2024-02-12 15:45:52 +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) (cherry picked from commit 7169c947ab4150a539f2af6c9dcf3ab4344b0033) --- 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 ecc73733b560..8cce52148699 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