From owner-svn-src-head@freebsd.org Sat Mar 11 06:24:50 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC1F3D06FC4; Sat, 11 Mar 2017 06:24:50 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AE66CDCF; Sat, 11 Mar 2017 06:24:50 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2B6OnQh081765; Sat, 11 Mar 2017 06:24:49 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2B6OnAL081763; Sat, 11 Mar 2017 06:24:49 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703110624.v2B6OnAL081763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 11 Mar 2017 06:24:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315054 - head/usr.bin/man X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Mar 2017 06:24:51 -0000 Author: bapt Date: Sat Mar 11 06:24:49 2017 New Revision: 315054 URL: https://svnweb.freebsd.org/changeset/base/315054 Log: Extend functionality MANPATH in man(1) to followup with apropos(1) from mandoc. If MANPATH begins with a colon, it is appended to the default list; if it ends with a colon, it is prepended to the default list; or if it contains two adjacent colons, the standard search path is inserted between the colons. If none of these conditions are met, it overrides the standard search path. Import the MANPATH description from mandoc into the man(1) man page Reported by: kargl MFC after: 1 week Modified: head/usr.bin/man/man.1 head/usr.bin/man/man.sh Modified: head/usr.bin/man/man.1 ============================================================================== --- head/usr.bin/man/man.1 Sat Mar 11 05:56:50 2017 (r315053) +++ head/usr.bin/man/man.1 Sat Mar 11 06:24:49 2017 (r315054) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 28, 2017 +.Dd March 11, 2017 .Dt MAN 1 .Os .Sh NAME @@ -295,13 +295,22 @@ Corresponds to the .Fl m option. .It Ev MANPATH -Used to find the location of the manual files. -See -.Xr manpath 1 -for additional information. -Corresponds to the -.Fl M -option. +The standard search path used by +.Xr man 1 +may be changed by specifying a path in the +.Ev MANPATH +environment variable. +Invalid paths, or paths without manual databases, are ignored. +Overridden by +.Fl M . +If +.Ev MANPATH +begins with a colon, it is appended to the default list; +if it ends with a colon, it is prepended to the default list; +or if it contains two adjacent colons, +the standard search path is inserted between the colons. +If none of these conditions are met, it overrides the +standard search path. .It Ev MANROFFSEQ Used to determine the preprocessors for the manual source before running .Xr nroff 1 Modified: head/usr.bin/man/man.sh ============================================================================== --- head/usr.bin/man/man.sh Sat Mar 11 05:56:50 2017 (r315053) +++ head/usr.bin/man/man.sh Sat Mar 11 06:24:49 2017 (r315054) @@ -68,7 +68,23 @@ build_manpath() { # If the user has set a manpath, who are we to argue. if [ -n "$MANPATH" ]; then - return + case "$MANPATH" in + *:) PREPEND_MANPATH=${MANPATH} ;; + :*) APPEND_MANPATH=${MANPATH} ;; + *::*) + PREPEND_MANPATH=${MANPATH%%::*} + APPEND_MANPATH=${MANPATH#*::} + ;; + *) return ;; + esac + fi + + if [ -n "$PREPEND_MANPATH" ]; then + IFS=: + for path in $PREPEND_MANPATH; do + add_to_manpath "$path" + done + unset IFS fi search_path @@ -82,6 +98,13 @@ build_manpath() { parse_configs + if [ -n "$APPEND_MANPATH" ]; then + IFS=: + for path in $APPEND_MANPATH; do + add_to_manpath "$path" + done + unset IFS + fi # Trim leading colon MANPATH=${manpath#:}