From nobody Tue Sep 16 13:59:24 2025 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 4cR3Rd3rhmz67JvN; Tue, 16 Sep 2025 13:59:25 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cR3Rc6rTJz3Xjm; Tue, 16 Sep 2025 13:59:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758031165; 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=BgMhQ9P+xJvoWVjnSQQUTh/UE4bMypOennYjxN8b/s0=; b=IDaRi5uNM3ZLr57Yu2XYH5xqAQETRHqllaSNLfNEcLfD66UvVKZEa8kEfcRCZIMsH+5dYr uwhRmevS331qwVeX422EcyDmqD+o35/MkKcNFKSRWGwKK0PlRtrkrjmSBgogFVF6DHn7Xq g/kPFbDiknP6F+BBXNi6XQomcExjsF+v/LPMGv5OcloJL7SZP0asFc40RxX+hGwWmoR30j /9nIGftZY6qGHknM49xtq2BAANn2wW/jQ6qs0FGdpgGVntI5SNgcHw5DsahyaVYeBitl40 TScX8BY7f4h60s8WS/j67G1PasPgQI2aQ7Dr+nRScQarxFdBNDLtxt5JcA+Nzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758031165; 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=BgMhQ9P+xJvoWVjnSQQUTh/UE4bMypOennYjxN8b/s0=; b=GGF63IO42yCSomm8DhU7Mwck8Tg8h5PTKX+bPluJ4zQ1p7OWqzSuTykKqw3kysH0kMTq26 Pdvxh2ViLOZ4S1QomTs4+WBczTWu2LdyOMPmjGrct+BKPhuAqNxAUJ1pEBRQ0EdI8pncKh 0OqUE9BP3Q6r8vDcpXiQe7OZAuTVCBsva+8uqfMjtwPdGCTXPxgrvMIpUqj8kqgNNVvIIp 8yz7tYobiQxtoW30vY6UpkXjp6njV3kGJYYH+jQAa+xmAxe4NYp2Tv17EKoalBkjBRFhXB ssUSvewHWAHT14nBF1p1KR0l8IFZq8+ajFHmVt1Aprz56prMLdFwMNtMmerPig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758031165; a=rsa-sha256; cv=none; b=UGAyO/GDvWIIu8Gd2/oJJFWryioGJIbWsF7Z5carYMgC6lwX6E3bATW7yQa1T4mGYkd6m/ dpzJAWmK2ar6liLC0vtUXL9sZhXbnCNZuObdM3nhOlSpju7KYxs5DkiryvlcsARwx8EJxm h3rOdoOxWNXVwrma6ou/VwX848PVWX17SS8NPEr3KqPSGpULTDkuMqQ7AH8qs4w5Rvx7GQ 2Cibqefn73qexboNYjvy/uwPAHrERRHAELN2/lvCDWaQRb4FxFPZLH+OrvTWTD/g1ZvMni WHaMTMle8B4dChxwW9GLa60ztGWDPolJfl5LKqRM27CxIXpw3MQccU8MgGP9Tw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cR3Rc6Hg2zjZF; Tue, 16 Sep 2025 13:59:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58GDxOnY064974; Tue, 16 Sep 2025 13:59:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58GDxOu1064971; Tue, 16 Sep 2025 13:59:24 GMT (envelope-from git) Date: Tue, 16 Sep 2025 13:59:24 GMT Message-Id: <202509161359.58GDxOu1064971@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: e5c5d8f78ead - stable/13 - man: Add -l option 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e5c5d8f78eade3a78825caf395c86fb9e7dccc82 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=e5c5d8f78eade3a78825caf395c86fb9e7dccc82 commit e5c5d8f78eade3a78825caf395c86fb9e7dccc82 Author: Ingo Schwarze AuthorDate: 2025-09-07 20:52:09 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-09-16 13:55:22 +0000 man: Add -l option Add a -l option which causes man to interpret all arguments as paths to open directly rather than man pages to search for in MANPATH. See the PR for a detailed rationale. PR: 289245 MFC after: 1 week Reviewed by: ziaee, emaste Differential Revision: https://reviews.freebsd.org/D52385 (cherry picked from commit 14b61b2e931741281d0bfef426e9809f16006504) --- usr.bin/man/man.1 | 25 ++++++++++++++++++++----- usr.bin/man/man.sh | 31 +++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 4bab5d78eea2..e524258cfbb4 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -31,7 +31,7 @@ .Nd display online manual documentation pages .Sh SYNOPSIS .Nm -.Op Fl adho +.Op Fl adhlo .Op Fl t | w .Op Fl M Ar manpath .Op Fl P Ar pager @@ -133,6 +133,15 @@ Display short help message and exit. .It Fl k Emulate .Xr apropos 1 . +.It Fl l +Interpret all arguments as absolute or relative filename(s) +of the manual page(s) to display. +No search is done and the options +.Fl M , +.Fl m , +and +.Fl S +are ignored. .It Fl m Ar arch Ns Op : Ns Ar machine Override the default architecture and machine settings allowing lookup of other platform specific manual pages. @@ -258,12 +267,15 @@ will search the following paths when considering section 4 manual pages in .Pa /usr/share/man/man4 .El .Ss Displaying Specific Manual Files -The +For compatibility reasons, .Nm -utility also supports displaying a specific manual page if passed a path -to the file as long as it contains a +will interpret any argument containing at least one .Ql / -character. +character as an absolute or relative path to a manual page to be +displayed. +This heuristic, made redundant by the more widely supported +.Fl l +option, is now deprecated and may be removed in future releases. .Sh ENVIRONMENT The following environment variables affect the execution of .Nm : @@ -390,6 +402,9 @@ manual page: $ man -w ls .Ed .Pp +Show a manual page in the current working directory: +.Pp +.Dl $ man -l man.1 .Sh SEE ALSO .Xr apropos 1 , .Xr intro 1 , diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 33be10cd5bd6..6bb260117078 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -495,13 +495,21 @@ man_display_page_groff() { # Usage: man_find_and_display page # Search through the manpaths looking for the given page. man_find_and_display() { - local found_page locpath p path sect + local found_page has_slash locpath p path sect # Check to see if it's a file. But only if it has a '/' in - # the filename. + # the filename or if -l was specified. case "$1" in - */*) if [ -f "$1" -a -r "$1" ]; then + */*) has_slash=yes + ;; + esac + if [ -n "$has_slash" -o -n "$lflag" ]; then + if [ -f "$1" -a -r "$1" ]; then decho "Found a usable page, displaying that" + if [ -z "$lflag" ]; then + echo "Opening a file directly is deprecated," \ + "use -l instead." >&2 + fi unset use_cat manpage="$1" setup_cattool "$manpage" @@ -510,9 +518,12 @@ man_find_and_display() { man_display_page fi return + elif [ -n "$lflag" ]; then + echo "Cannot read $1" >&2 + ret=1 + return fi - ;; - esac + fi IFS=: for sect in $MANSECT; do @@ -580,7 +591,7 @@ man_parse_opts() { local cmd_arg OPTIND=1 - while getopts 'M:P:S:adfhkm:op:tw' cmd_arg; do + while getopts 'M:P:S:adfhklm:op:tw' cmd_arg; do case "${cmd_arg}" in M) MANPATH=$OPTARG ;; P) MANPAGER=$OPTARG ;; @@ -590,6 +601,7 @@ man_parse_opts() { f) fflag=fflag ;; h) man_usage 0 ;; k) kflag=kflag ;; + l) lflag=lflag ;; m) mflag=$OPTARG ;; o) oflag=oflag ;; p) MANROFFSEQ=$OPTARG ;; @@ -602,12 +614,15 @@ man_parse_opts() { shift $(( $OPTIND - 1 )) # Check the args for incompatible options. - case "${fflag}${kflag}${tflag}${wflag}" in + case "${fflag}${kflag}${lflag}${tflag}${wflag}" in fflagkflag*) echo "Incompatible options: -f and -k"; man_usage ;; + fflag*lflag*) echo "Incompatible options: -f and -l"; man_usage ;; fflag*tflag*) echo "Incompatible options: -f and -t"; man_usage ;; fflag*wflag) echo "Incompatible options: -f and -w"; man_usage ;; - *kflagtflag*) echo "Incompatible options: -k and -t"; man_usage ;; + *kflaglflag*) echo "Incompatible options: -k and -l"; man_usage ;; + *kflag*tflag*) echo "Incompatible options: -k and -t"; man_usage ;; *kflag*wflag) echo "Incompatible options: -k and -w"; man_usage ;; + *lflag*wflag) echo "Incompatible options: -l and -w"; man_usage ;; *tflagwflag) echo "Incompatible options: -t and -w"; man_usage ;; esac