Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Aug 2011 20:27:19 +0400
From:      Test Rat <ttsestt@gmail.com>
To:        Gordon Tetlow <gordon@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, Alexander Best <arundel@freebsd.org>, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r213507 - head/usr.bin/man
Message-ID:  <86obzsot5k.fsf@gmail.com>
In-Reply-To: <201010070634.o976YlOG030724__26866.5940188386$1286433305$gmane$org@svn.freebsd.org> (Gordon Tetlow's message of "Thu, 7 Oct 2010 06:34:47 %2B0000 (UTC)")
References:  <201010070634.o976YlOG030724__26866.5940188386$1286433305$gmane$org@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Gordon Tetlow <gordon@FreeBSD.org> writes:

> Author: gordon
> Date: Thu Oct  7 06:34:47 2010
> New Revision: 213507
> URL: http://svn.freebsd.org/changeset/base/213507
>
> Log:
>   Add the ability to display specific manual pages if passed on the
>   commandline. This mirrors the old (undocumented) GNU man functionality.
>   Also document this feature in the implementation notes section of
>   the manpage.
>
>   Submitted by:	arundel
>   Approved by:	wes (mentor implicit)

Why the limitation? It's rather painful to prefix manpages with $PWD
on command line. And a useful case of displaying generated on-the-fly
manpages is missed, too, irrespective of GNU man.

  $ man dup.2
  $ texi2pod.pl ffmpeg.texi | pod2man | man

%%
Index: usr.bin/man/man.sh
===================================================================
--- usr.bin/man/man.sh	(revision 224842)
+++ usr.bin/man/man.sh	(working copy)
@@ -403,10 +403,9 @@
 man_find_and_display() {
 	local found_page locpath p path sect
 
-	# Check to see if it's a file. But only if it has a '/' in
-	# the filename.
-	case "$1" in
-	*/*)	if [ -f "$1" -a -r "$1" ]; then
+	# Check to see if it's a troff file.
+	case $(file --brief --mime-type "$1") in
+	text/troff)	if [ -f "$1" -a -r "$1" ]; then
 			decho "Found a usable page, displaying that"
 			unset use_cat
 			manpage="$1"
@@ -898,12 +897,16 @@
 
 do_man() {
 	man_parse_args "$@"
-	if [ -z "$pages" ]; then
+	if [ -z "$pages" -a -t 0 ]; then
 		echo 'What manual page do you want?' >&2
 		exit 1
 	fi
 	man_setup
 
+	if [ ! -t 0 ]; then
+	    man_display_page
+	fi
+
 	for page in $pages; do
 		decho "Searching for $page"
 		man_find_and_display "$page"
Index: usr.bin/man/man.1
===================================================================
--- usr.bin/man/man.1	(revision 224842)
+++ usr.bin/man/man.1	(working copy)
@@ -232,9 +232,7 @@
 The
 .Nm
 utility also supports displaying a specific manual page if passed a path
-to the file as long as it contains a
-.Ql /
-character.
+to the file as long as it's a troff file.
 .Sh ENVIRONMENT
 The following environment variables affect the execution of
 .Nm :
%%



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86obzsot5k.fsf>