#! /bin/sh

test -z "${BIN_DIR}" && BIN_DIR=website/cgi-bin

SCRIPT_BASE=`basename $0 | sed "s/_[0-9]*\.sh$//"`

#BEGIN DEPEND------------------------------------------------------------------

INPUT_SCRIPT="${BIN_DIR}/${SCRIPT_BASE}"

#END DEPEND--------------------------------------------------------------------

set -ue
## set -x

BASENAME=$(basename $0 .pl)
TMP_TEST_DB=$(echo tmpNonexistent${BASENAME}$$ | sed 's/[^-0-9a-zA-Z]//g').db

DB_DIR=db
TMP_DB_FILE=${DB_DIR}/${TMP_TEST_DB}

export REQUEST_URI="/~saulius/restful/website/${TMP_TEST_DB}/bibliography"
export HTTP_HOST=${TMP_TEST_DB}.domain.net
export REQUEST_METHOD=get

${INPUT_SCRIPT} | perl -lpe 's/database .*?([^\/]+) does not/database '\''$1 does not/'

rm -f ${TMP_DB_FILE}
