From nobody Wed Sep 28 06:11:42 2022 X-Original-To: dev-commits-doc-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 4McmNG2KDdz4cltK for ; Wed, 28 Sep 2022 06:11:42 +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 4McmNG1vk6z3sCn; Wed, 28 Sep 2022 06:11:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664345502; 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=Ts2DX586esDsU6VWumdHKMF8I9ZaEnHlgztAzAuaIlc=; b=K/WNeqCWC+dHTzsH07E/btiGQIBoDCGXWabFf8PsmI7JLS5tHeAJcJAAAd7oZnBHrhXC+I PyjgRXm2copHFiWdcOOWa08lcBOtyH8i59s4/ERokfKgLOiIezgzOhumgZGh8f16I7c4dL Qmzews4+3Ja/xd5nNlb7z9AA2VeRop9fkYv1HH6nOklodKOMDvQ4jatJohrSyEuTrsFwe+ PoUIdz0a2JkH0IyWAWAo76iLGoS6c2Vus4nAD3tkSiUWzO34w487SxGcxu8uz0sjStJLot SADpgTLitFYUd7MCg74RZBzfE62CjercEkxD2HRGzTYPR80fpUi9FIs2HJf8+w== 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 4McmNG0yDgzN8W; Wed, 28 Sep 2022 06:11:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28S6BgDU030311; Wed, 28 Sep 2022 06:11:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28S6BgFj030310; Wed, 28 Sep 2022 06:11:42 GMT (envelope-from git) Date: Wed, 28 Sep 2022 06:11:42 GMT Message-Id: <202209280611.28S6BgFj030310@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Wolfram Schneider Subject: git: f42891ebcf - main - Give base manual page higher priority than ports manual pages List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-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: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f42891ebcfffa433f1826a102014e68a284f1c0a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664345502; 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=Ts2DX586esDsU6VWumdHKMF8I9ZaEnHlgztAzAuaIlc=; b=K5gtyW57+y9/2nsgRJaIhCmqEni2cUPP4iJanCTvMOYtH/OSp9hjnwRXwlczZ8St3Uz6/q mk4/7UXsi+ErKDCAepPHhBf3SpdSQZBvqcoxNFHlvuEvAfHO7pG2FN8CfvvAn1pJbWN1Zw Wyp31N1WpTfhlJft0mx29ultQxeP8yLqtXhBkcclaTcUAin2RcnoZv1st7jF6kjd6uib3W AfGJOCL1ElqWzGySExvPODTCOutegwL5qcMM6hmi3XAEdBCNJirkJylJg1j4gM973ASJT4 9XdIf5AxqtOBDs8NujcM+debXcaknKa9GZGuEKjbL2ITZuxqLOWh3EXElsXM7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664345502; a=rsa-sha256; cv=none; b=KX4mndRFdSS3dYaIvK5PbwxnkrsXxn78syrCFX2L/fF9lDfuwbUGZ9uMzIsqPIbE0B9dr9 pdnZrhIWIrlUAMxACl7hgWYZLXnS7KanLWNHf+f3EyxfNtknQTgtnO07VBPSIoKWw1n8/n U5BAY4O9sw72DBvx719l4AAfIKGvesB0OlQsvbe+6kfszQKdAjISoaF8vGHEnb93tZwyrZ hvFyc/Cc95DCJHTLIIdW+hdAXTdy1P1hhNfFw8hYkvn1GPzLgjhl8Mv2nPfoPC0UJpfaxU k/Gus02YZqa+adji4XhIiQkDaqPir6AGkQOGPmnEnsDeOMmekK09XLp4VPGKyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/doc/commit/?id=f42891ebcfffa433f1826a102014e68a284f1c0a commit f42891ebcfffa433f1826a102014e68a284f1c0a Author: Wolfram Schneider AuthorDate: 2022-09-28 06:09:26 +0000 Commit: Wolfram Schneider CommitDate: 2022-09-28 06:09:26 +0000 Give base manual page higher priority than ports manual pages First look in the FreeBSD base manual pages (aka /usr/share/man) and then in FreeBSD ports (aka /usr/local/man). This avoids confusion when manual pages have have the same name, but are in different sections. In this case, a ports manual pages would win because of the higher section priority. Now, searching for "socket" will always show socket(2) from the base system and not socket(1) from ports PR: 264054 Reported by: grog --- website/content/en/cgi/man.cgi | 50 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/website/content/en/cgi/man.cgi b/website/content/en/cgi/man.cgi index 33774877a7..3d01c53605 100755 --- a/website/content/en/cgi/man.cgi +++ b/website/content/en/cgi/man.cgi @@ -59,6 +59,13 @@ my $download_streaming_caching = 0; #$command{'man'} = '/usr/bin/man'; # 8Bit clean man $command{'man'} = '/usr/local/www/bin/man.wrapper'; # set CPU limits +# First look in the FreeBSD base manual pages (aka /usr/share/man) and then +# in FreeBSD ports (aka /usr/local/man). This avoids confusion when manual pages have +# have the same name, but are in different sections. In this case, a ports manual +# pages would win because of the higher section priority. Now, searching for "socket" +# will always show socket(2) from the base system and not socket(1) from ports +my $freebsd_base_manpages_first = 1; + # Config Options # map sections to their man command argument(s) %sections = ( @@ -1395,6 +1402,18 @@ sub to_filename { return $filename; } +# strip ports manual pages from path +sub manpath_without_ports { + my $path = shift; + + my @list; + foreach my $p (split(/:/, $path)) { + push @list, $p if $p !~ /-ports-/; + } + + return join(":", @list); +} + sub man { local ( $name, $section, $arch ) = @_; local ( $_, $title, $head, *MAN ); @@ -1502,13 +1521,15 @@ sub man { } @manargs = split( / /, $section ); + my $manpath_m = ""; + if ($manpath) { if ( $manPath{$manpath} ) { - unshift( @manargs, ( '-M', $manPath{$manpath} ) ); + $manpath_m = $manPath{$manpath}; &groff_path( $manPath{$manpath} ); } elsif ( $manpath{ &dec($manpath) } ) { - unshift( @manargs, ( '-M', $manPath{ &dec($manpath) } ) ); + $manpath_m = $manPath{ &dec($manpath) }; &groff_path( $manPath{ &dec($manpath) } ); } else { @@ -1524,12 +1545,31 @@ sub man { push( @manargs, '-t' ); } - warn "X $command{'man'} @manargs -- x $name x\n" if $debug >= 3; push( @manargs, ( "-m", $arch ) ) if $arch; - &proc( *MAN, $command{'man'}, @manargs, "--", $name ) - || &mydie("$0: open of $command{'man'} command failed: $!\n"); + # search first for base manual pages, and maybe later in ports + if ($freebsd_base_manpages_first && $section eq "" && $manpath =~ m/ and Ports$/) { + warn "search for base pages first: $name\n" if $debug >= 2; + my @m = ("-M", &manpath_without_ports($manpath_m)); + warn "X $command{'man'} @m @manargs -- x $name x\n" if $debug >= 3; + &proc( *MAN, $command{'man'}, @m, @manargs, "--", $name ) + || &mydie("$0: open of $command{'man'} command failed: $!\n"); + + if ( eof(MAN) ) { + warn "search for ports pages as well: $name\n" if $debug >= 2; + @m = ("-M", $manpath_m); + warn "X $command{'man'} @m @manargs -- x $name x\n" if $debug >= 3; + &proc( *MAN, $command{'man'}, @m, @manargs, "--", $name ) + || &mydie("$0: open of $command{'man'} command failed: $!\n"); + } + } else { + my @m = $manpath_m ? ("-M", $manpath_m) : (); + warn "X $command{'man'} @m @manargs -- x $name x\n" if $debug >= 3; + &proc( *MAN, $command{'man'}, @m, @manargs, "--", $name ) + || &mydie("$0: open of $command{'man'} command failed: $!\n"); + } + if ( eof(MAN) ) { if ( $format eq "ascii" ) { print "Sorry, no data found for '$html_name'\n";