#!/bin/sh

if [ -z ${QUERY_STRING} ]; then
    printf "10 Please enter your comment and name: \r\n"
fi

DECODED=`echo ${QUERY_STRING} | perl -pe 's/\%(\w\w)/chr hex $1/ge' `
echo "\n"$DECODED >> ../guestbook.gmi

# too much empty lines between comments
sed -i -z -e 's/\n\{4,\}/\n\n\n/g' ../guestbook.gmi

printf "30 ../guestbook.gmi\r\n"