aboutsummaryrefslogtreecommitdiffstats
path: root/main/mdocml/man.sh
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-07-12 11:12:54 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-07-12 11:12:54 +0000
commit99d7d8fe29928dcbe72e1166424db141a13b0103 (patch)
tree6d35a906137e3bf65702f154b4bae4aa5e099142 /main/mdocml/man.sh
parent924e653655223ffbb3a028f101547e4f85921f95 (diff)
downloadaports-99d7d8fe29928dcbe72e1166424db141a13b0103.tar.bz2
aports-99d7d8fe29928dcbe72e1166424db141a13b0103.tar.xz
main/mdocml: moved from testing
Diffstat (limited to 'main/mdocml/man.sh')
-rw-r--r--main/mdocml/man.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/main/mdocml/man.sh b/main/mdocml/man.sh
new file mode 100644
index 0000000000..6795e2007d
--- /dev/null
+++ b/main/mdocml/man.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# man - a simple man program for ASCII pages
+# Copyright (c) 2008 Matthew Hiles
+#
+# Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+
+## requires: find, head, sort, tr, cat, and grep/egrep
+## optional: zcat, bzcat, less
+
+if [ -z "$MANPATH" ]; then
+ echo "Warning: MANPATH is not set, assuming /usr/share/man." >&2
+ MANPATH=/usr/share/man
+fi
+
+case $# in
+1)
+ pagearg=$1 ;;
+2)
+ section=man$1
+ pagearg=$2 ;;
+*)
+ echo "Usage: man [section] <manpage>"
+ exit
+esac
+
+paths=`echo "$MANPATH" | tr ":" " "`
+pagefile=`find $paths | grep "/$section" | grep "/$pagearg\." | sort | head -n1`
+
+if [ -z "$pagefile" ]; then
+ echo -n No manual entry for $pagearg
+ [ $section ] && echo -n " in section $1 of the manual."
+ echo
+ exit
+fi
+
+[ "$PAGER" ] || PAGER=less
+tty -s <&1 || PAGER=cat
+
+case "$pagefile" in
+*.bz2)
+ exec bzcat "$pagefile" | "$PAGER" ;;
+*.gz)
+ exec zcat "$pagefile" | "$PAGER" ;;
+*)
+ exec mandoc -Tutf8 "$pagefile" | "$PAGER" ;;
+esac
+
+paths=
+pagefile=
+pagearg=
+section=