#!/bin/sh
echo "Content-type: text/html\n\n"
query="${QUERY_STRING}"
echo "
"
echo "Search for:
"
terms=$(echo "${query}" | tr '&' '\n' | grep -E "^query" | sed -E 's/^query=//')
if [ -z "$terms" ]; then
exit 0
else
search=$(echo "$terms" | sed -E 's/\+/ /g')
res=$(./search_repo ./ $search )
if [ -z "$res" ]; then
echo "No results for \"$search\":"
exit 0;
else
echo "
Results for \"$search\""
echo "
\n"
for r in $res; do
echo "\n"
done
echo "
"
fi
fi