svn commit: r213507 - head/usr.bin/man

Test Rat ttsestt at gmail.com
Sun Aug 14 16:27:26 UTC 2011


Gordon Tetlow <gordon at 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 :
%%


More information about the svn-src-all mailing list