#!/bin/sh error () { echo "ERROR: $1" exit 1 } setup () { [ -z "$PAGER" ] && PAGER=less DIR="$HOME" [ -z "$DIR" ] && DIR="/tmp/" [ ! -d "$DIR" ] && error "sorry i need $DIR for temp files" if [ -n "`which tempfile`" ]; then tmp=`tempfile -d $DIR --prefix=.` [ -e "$tmp" ] || error "failed to create temp file $tmp!" else tmp=$DIR/man.$$ if [ ! -e "$tmp" ] ; then >$tmp else error " $tmp! created for other user" fi fi trap "rm -rf $tmp" 1 2 3 9 15 if [ -n "`which lynx`" ]; then DOWNLOAD="lynx --dump --nolist"; elif [ -n "`which links`" ]; then DOWNLOAD="links -dump"; elif [ -n "`which w3ma`" ]; then DOWNLOAD="w3m -dump -T text/html -s"; else error "you have to install lynx, links or w3m"; fi } [ -z "$1" ] && error "use: $0 command" setup $DOWNLOAD "http://man.linuxquestions.org/?query=$1" > $tmp [ $? -ne 0 ] && error "error while reading online man" if [ -f "$tmp" ] then cat $tmp 2> /dev/null | tail -n $((`wc -l $tmp 2> /dev/null | awk '{ print $1 ;}'`-2)) | $PAGER echo rm $tmp else error "error reading $tmp" fi