From: Colin Watson Date: Mon, 6 Jan 2003 03:52:13 +0000 (+0000) Subject: debman: New script to read man pages straight out of .debs. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=commitdiff_plain;h=f6d0d20ca32c1052e4b4fb22da61eb3fcf258d48 debman: New script to read man pages straight out of .debs. --- diff --git a/debman b/debman new file mode 100755 index 0000000..25a5f1a --- /dev/null +++ b/debman @@ -0,0 +1,53 @@ +#! /bin/sh -e + +# debman - read a man page from an uninstalled Debian package file (.deb) + +# Copyright (C) 2003 Colin Watson + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +USAGE='Usage: debman [man options] ...' + +case "$1" in + -h|--help) + echo "$USAGE" + exit 0 + ;; +esac + +if test $# -lt 2; then + echo "$USAGE" >&2 + exit 1 +fi + +# Directory names are duplicated with and without ./ in order to cope with +# old .debs whose data.tar.gz components had a slightly different format. +MANDIRS='usr/share/man usr/X11R6/man ./usr/share/man ./usr/X11R6/man' + +TEMPDIR=`mktemp -dt debman.XXXXXXXXXX` +trap 'rm -rf "$TEMPDIR"' EXIT ERR HUP INT QUIT TERM + +# Ignore errors from tar (though not dpkg). They'll generally just be of the +# form "tar: usr/share/man: Not found in archive". If they're something +# else, then man will fail to find the page anyway. + +dpkg --fsys-tarfile "$1" | \ + (tar -C "$TEMPDIR" -xf - $MANDIRS 2>/dev/null || true) +shift + +MANPATH="$TEMPDIR/usr/share/man:$TEMPDIR/usr/X11R6/man" man "$@" + +# vi: expandtab