#!/usr/bin/env bash PAGE=${PATH_INFO#*/} if [ ! -z "$PAGE" ]; then echo -e 'Content-Type: text/plain\n' echo "$PAGE" | egrep '^[A-Za-z_.][A-Za-z_.-]*$' &> /dev/null if [ ! $? = 0 ]; then echo Invalid input: "$PAGE" else man "$PAGE" 2> /dev/null | col -b || \ echo Sorry, there was an error. fi else echo -e 'Content-Type: text/html\n' echo '

Try e.g. man cat.

' fi