Created
October 30, 2016 23:49
-
-
Save spchamp/aed53ad4e1d04b80ebfd588c638b049c to your computer and use it in GitHub Desktop.
PDF generator for manual pages in *ROFF format. runtime-depends on ports textproc/groff and print/ghostscript9-base. Public domain. No warranty.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
THIS="$(basename $(readlink -f $0))" | |
msg() { | |
echo "$THIS: $@" | |
} | |
ferr() { | |
msg $@ 1>&2 | |
exit 1 | |
} | |
if [ -z "$1" ]; then | |
ferr "no query specified" | |
fi | |
if [ -n "$2" ] | |
then | |
OUTF="$1.$2.pdf" | |
QUERY="$2 $1" | |
NAME="$1($2)" | |
else | |
OUTF="$1.pdf" | |
QUERY="$1" | |
NAME="$1(*)" | |
fi | |
ONOTIF="Generated file ${OUTF}" | |
msg "Querying for manual page ${NAME}" | |
MPATH="$(man -w ${QUERY} 2>/dev/null)" | |
if [ -n "$MPATH" ]; then | |
zcat "${MPATH}" | | |
groff -mandoc -T ps -dpaper=a4 -P-pa4 | | |
ps2pdf - "${OUTF}" && msg "$ONOTIF" | |
else | |
ferr "No manual page found: ${NAME}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment