#!/bin/sh # cacophony by C. Duckworth --- public domain SCRIPTDIR=source crlf() { # crlf < INPUT ## Convert LF to CRLF sed 's/$/ /g' } http_header() { # header [STATUS] cat <
copyright (C) $(stat -c %y "$1" | cut -d- -f1) Case Duckworth. this page is a program served by cacophony. EOF } hexec() { # hexec PROGRAM [header args] prog="$1"; shift http_header "$@" "$prog" html_footer "$prog" } run() { # run echo "$PATH_INFO" >> /tmp/pathinfo if test / = "$PATH_INFO" || test "/cacophony.sh" = "$PATH_INFO" then PATH_INFO=/index run else path="$PWD/$SCRIPTDIR$PATH_INFO" if ! test -d "$path" && test -x "$path" then hexec "$path" 200 else http_header 404 fi fi } run