bin/161475: [patch] man(1), treat pipe & files w/o slash
Nali Toja
nalitoja at gmail.com
Mon Oct 10 21:50:10 UTC 2011
>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 at 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:
More information about the freebsd-bugs
mailing list