#!/bin/sh
#Gopher Shell - The unintelligent Gopher server, written in sh.
#Written in 2019 by Prince Trippy programmer@verisimilitudes.net .

#To the extent possible under law, the author(s) have dedicated all copyright
#and related and neighboring rights to this software to the public domain worldwide.
#This software is distributed without any warranty.

#You should have received a copy of the CC0 Public Domain Dedication along with this software.
#If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

#You should run this with a controlling program, such as xinetd.
set -e
trap "printf '3The provided selector is invalid.\t\tverisimilitudes.net\t70\r\n.\r\n'" ERR
head -n 1 | head -c 64 | tr -d "\0\r\t [='=][=\"=]" | sed 's/^$/map/g' |
xargs printf '/var/gopher/%s\n' | sed 's/\.\.//g' | tee -a /var/log/gopherhole 2> /dev/null |
xargs cat 2> /dev/null