Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'For the shell-scripting challenged...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
For the shell-scripting challenged...
Authored by: superfly on Nov 13, '03 09:36:14AM
this version gets the section right if it's not given.

#!/bin/sh
CACHE=/tmp/preman

if [ ! $1 ]; then
    # give man's wtf error
    man
    exit
fi

# get manpage name
MANPAGE=`man -w $@`
if [ ! $? = 0 ]; then  # not found
    # man will have printed an error
    exit
fi

MANPAGE=`basename $MANPAGE`
PDF=$CACHE/$MANPAGE.pdf

# create cache if it doesn't exist
if [[ ! -d $CACHE ]]; then
    mkdir -p $CACHE
fi

# if there's no cached pdf, make one
if [[ ! -r $PDF ]]; then
    man -t $@ | pstopdf -i -o $PDF
fi

open $PDF


[ Reply to This | # ]