From nobody Sun Sep 7 20:53:03 2025 X-Original-To: dev-commits-src-main@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 4cKj333gPMz66lNw; Sun, 07 Sep 2025 20:53:03 +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 4cKj332XnPz3FV8; Sun, 07 Sep 2025 20:53:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757278383; 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=+cq/pwZfRo164ql+pQsP7KWPG3Kxm1yAIkWb36DMBbE=; b=ZsguZ7cFRuVJgV9x+r73eXLUjDhgF3Pt2O5lTjUHfj0l/YByWIB485n8FnG4QAO/QUW4Ux puA3Zy2CS9/1Brmkip+8jFiBQBzZp2KXM1LfWYhLe1BqjoghnGzPeWgeDti6RM3mNQzd9w xzInNvML4AaVpKDRc8bxRxlRyRJbdUezctGSeFg1LPRyAZ+eV6xN/4kdwtwdqjaiikl2fy b5i0hfhyp1bkrfhMWJvTYN1aX3nOZln7mbhPBIgyN0fZd5gi7Ndh32OYUYKzozUkwS55/3 4TWvMA5qbKnSkUOZiIOUVYLzyD305me01OHPwtpwCO4X0jtv91FRLLqrzL11JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1757278383; 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=+cq/pwZfRo164ql+pQsP7KWPG3Kxm1yAIkWb36DMBbE=; b=WzvMPaUhUmH3e0r7MIc6FarpND4mJb0+c/1/6DrXjPmYoKGynXKMGEHdHCCPs1XDUUK2Ec TeutHK2BTn8UifdkNdiybIvCuGILNgBpqm1hm3lGwmbj4ityBl91/j3OYMRjyLThiBe9NI QiXJWNzUkazLoA0v5dZiKQKcz23FC5UbPF+XSEBcqK78uJforKMU6sOlNIUilvYj3WgUE5 KBrIBIGTkpCwsSBxTZJ3OER/mKUdOWyF7837ht8VIA9YIqHuFdS7weiahOl/r9nKG7Ow36 V3KrlZ1RahsYoDghSUg9Qkf6SrmnUv3X3j0NsM9CPEmXFhf9U7N9ODJ2J8q7qw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1757278383; a=rsa-sha256; cv=none; b=rneWBJDL3QHdspd01uhuR9ooTObXSUc82hhg6B43T8JBOHHgQNaIy1Y2pGY0EZPANlKRBJ c0O/FLE/uwrVg4Q2ouMK7sf1s6dPN4j7Y0hvhIH/RNYkfEgdOQDTOvPvIO8E9ZS9+8E2Sg IqFklt5rTXAq5/YP/DkcalwwceZTIPwm2Mec4LYYkmAliFZiiz+R+FGavIjDQfV2p9WfRv hpG5LJhLZyZIbtM1T/Q/VjuryU79NUB4HOtw7Jtm4DFw/AGhJDmYOwt28iXXDeVPDdFLDB mJ4wzBXqEZuoB5qjYHnHH1kem/dYnSlBf93rA9HzZDp51cQlJpngxdHPnF4cnQ== 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 4cKj331z0Lzcdh; Sun, 07 Sep 2025 20:53:03 +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 587Kr3Pb046988; Sun, 7 Sep 2025 20:53:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 587Kr3uE046985; Sun, 7 Sep 2025 20:53:03 GMT (envelope-from git) Date: Sun, 7 Sep 2025 20:53:03 GMT Message-Id: <202509072053.587Kr3uE046985@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 14b61b2e9317 - main - man: Add -l option List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 14b61b2e931741281d0bfef426e9809f16006504 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=14b61b2e931741281d0bfef426e9809f16006504 commit 14b61b2e931741281d0bfef426e9809f16006504 Author: Ingo Schwarze AuthorDate: 2025-09-07 20:52:09 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-09-07 20:52:09 +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 --- usr.bin/man/man.1 | 24 ++++++++++++++++++------ usr.bin/man/man.sh | 33 ++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 820d6a5b33a9..707677ccce06 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -33,7 +33,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 @@ -144,6 +144,15 @@ Search names and descriptions of all manual pages for an extended regular .Ar expression , emulating basic functionality of .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. @@ -269,12 +278,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 : @@ -398,7 +410,7 @@ manual page: .Pp Show a manual page in the current working directory: .Pp -.Dl $ man ./man.1 +.Dl $ man -l man.1 .Pp Show the location of manual pages in sections 1 and 8 which contain the word .Ql arm : diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 18595042da5f..53961ae4997e 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -511,13 +511,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" @@ -531,9 +539,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 @@ -601,7 +612,7 @@ man_parse_opts() { local cmd_arg OPTIND=1 - while getopts 'K:M:P:S:adfhkm:op:tw' cmd_arg; do + while getopts 'K:M:P:S:adfhklm:op:tw' cmd_arg; do case "${cmd_arg}" in K) Kflag=Kflag REGEXP=$OPTARG ;; @@ -613,6 +624,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 ;; @@ -625,16 +637,19 @@ man_parse_opts() { shift $(( $OPTIND - 1 )) # Check the args for incompatible options. - - case "${Kflag}${fflag}${kflag}${tflag}${wflag}" in + case "${Kflag}${fflag}${kflag}${lflag}${tflag}${wflag}" in Kflagfflag*) echo "Incompatible options: -K and -f"; man_usage ;; Kflag*kflag*) echo "Incompatible options: -K and -k"; man_usage ;; + Kflag*lflag*) echo "Incompatible options: -K and -l"; man_usage ;; Kflag*tflag) echo "Incompatible options: -K and -t"; man_usage ;; 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