#!/bin/sh ##func printlines (){ echo "\n" } printf "Content-type: text/html\n\n" query=$(echo "${QUERY_STRING}" | sed -E 's/["\\$^?<>@;*`|/()]//g') ##func print_head(){ echo "" echo "
Search for:
" echo "
" echo "
in: url" echo "description" echo "readme" echo "all" echo "
" echo "" echo "
" } ##func print_foot(){ echo "" } terms=$(echo "${query}" | tr '&' '\n' | grep -E "^query=" | sed -E 's/^query=//') qtype=$(echo "${query}" | tr '&' '\n' | grep -E "^type=" | sed -E 's/^type=//') print_head if [ -n "$terms" ]; then search=$(echo "$terms" | sed -E 's/\+/ /g') numres=0 lines=$(./search_repo ./ "$search" 2>&1 ) for line in $lines; do case "$line" in "--URL") #echo "$line
" if [ "$qtype" = "url" -o "$qtype" = "all" ]; then curstr="url" else curstr="" fi ;; "--DESCR") if [ -n "$curstr" ]; then if [ -n "$results" ]; then printf "
%s results in repo %s
\n" $numres $curstr printlines "$results" else printf "
No results in repo %s
\n" $curstr fi fi results="" numres=0 if [ "$qtype" = "descr" -o "$qtype" = "all" ]; then curstr="description" else curstr="" fi ;; "--README") #echo "$line
" if [ -n "$curstr" ]; then if [ -n "$results" ]; then printf "
%s results in repo %s
\n" $numres $curstr printlines "$results" else printf "
No results in repo %s
\n" $curstr fi fi results="" numres=0 if [ "$qtype" = "read" -o "$qtype" = "all" ]; then curstr="readme" else curstr="" fi ;; *) numres=$(($((numres)) + 1)) results="$results $line" ;; esac done if [ -n "$curstr" ]; then if [ -n "$results" ]; then printf "
%s results in readme files
\n" $numres printlines $results else printf "
No results in readme files
\n" $curstr fi fi fi print_foot