Contents of file "man.cgi"

#!/usr/pkg/bin/bash
# man.cgi Copyright (C) 2003 jc@jcomeau.com
# Free software per GNU Public License
# security improvements thanks to Eli the Bearded
file=`echo $QUERY_STRING | tr -cd 'A-Za-z0-9\._:\-'`; # keep crackers out
export TERM=html # in case by some miracle it should work
export PATH=/bin:/usr/bin:/usr/pkg/bin
echo -ne Content-type: text/html\\r\\n\\r\\n
echo '<HTML><HEAD><TITLE>manpage</TITLE></HEAD><BODY><PRE>'
man $file 2>/dev/null | perl -pe '
  s/</&lt;/g; # get rid of anything resembling an HTML tag in manpage
  s/(&lt;|.)\cH\1/<B>$1<\/B>/g; # boldface anything doubled around backspace
  s/_\cH(&lt;|.)/<U>$1<\/U>/g; # underline anything preceded by _^H
  s/^$/<P>/; # insert paragraph where blank line found
 '
echo '</PRE></BODY></HTML>'