From nalitoja@gmail.com  Mon Oct 10 21:43:11 2011
Return-Path: <nalitoja@gmail.com>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7CCB4106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Oct 2011 21:43:11 +0000 (UTC)
	(envelope-from nalitoja@gmail.com)
Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182])
	by mx1.freebsd.org (Postfix) with ESMTP id 14D438FC16
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Oct 2011 21:43:10 +0000 (UTC)
Received: by wyj26 with SMTP id 26so9888929wyj.13
        for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Oct 2011 14:43:09 -0700 (PDT)
Received: by 10.223.75.137 with SMTP id y9mr34802610faj.14.1318282989792;
        Mon, 10 Oct 2011 14:43:09 -0700 (PDT)
Received: from nil (exit-01a.noisetor.net. [173.254.216.66])
        by mx.google.com with ESMTPS id n1sm33829267fad.20.2011.10.10.14.42.59
        (version=SSLv3 cipher=OTHER);
        Mon, 10 Oct 2011 14:43:09 -0700 (PDT)
Message-Id: <864nzg7cc8.fsf@gmail.com>
Date: Mon, 10 Oct 2011 21:42:31 +0000
From: Nali Toja <nalitoja@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] man(1), treat pipe & files w/o slash

>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:
