Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Oct 2011 21:42:31 +0000
From:      Nali Toja <nalitoja@gmail.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/161475: [patch] man(1), treat pipe & files w/o slash
Message-ID:  <864nzg7cc8.fsf@gmail.com>
Resent-Message-ID: <201110102150.p9ALo9qS030195@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         161475
>Category:       bin
>Synopsis:       [patch] man(1), treat pipe & files w/o slash
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 10 21:50:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Nali Toja
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
>Description:
- treat pipe as a manpage
- allow to view files that do no start with path delimiter

cf. http://docs.freebsd.org/cgi/mid.cgi?20110814171617.GA4980
>How-To-Repeat:
$ man dup.2
$ texi2pod.pl ffmpeg.texi | pod2man | man
$ ssh foo@bar cat /path/to/man.1.xz | man
>Fix:
--- view_as_manpage.diff begins here ---
Index: usr.bin/man/man.sh
===================================================================
--- usr.bin/man/man.sh	(revision 226114)
+++ usr.bin/man/man.sh	(working copy)
@@ -404,8 +404,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.
+	# the filename or looks like a manpage.
 	case "$1" in
+	*.[0-9ln]*) ;& # fallthrough
 	*/*)	if [ -f "$1" -a -r "$1" ]; then
 			decho "Found a usable page, displaying that"
 			unset use_cat
@@ -898,12 +899,17 @@ do_apropos() {
 
 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
+	    decho "Displaying from stdin"
+	    man_display_page
+	fi
+
 	for page in $pages; do
 		decho "Searching for $page"
 		man_find_and_display "$page"
--- view_as_manpage.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:



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