diff options
-rwxr-xr-x | search_cgi | 33 |
1 files changed, 22 insertions, 11 deletions
@@ -1,5 +1,7 @@ #!/bin/sh +## function definitions ## + ##func printlines (){ printf "<ul>\\n" @@ -12,7 +14,6 @@ printlines (){ -query=$(echo "${QUERY_STRING}" | sed -E 's/["\\$^?<>@;*`|/()]//g') ##func print_head(){ @@ -38,16 +39,9 @@ print_foot(){ echo "</body></html>" } -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 +##func +print_results(){ + for line in $@; do case "$line" in "--URL") #echo "$line<br>" @@ -109,6 +103,23 @@ if [ -n "$terms" ]; then printf "<div>No results in readme files </div>\\n" fi fi +} + + +## main loop ## + +query=$(echo "${QUERY_STRING}" | sed -E 's/["\\$^?<>@;*`|/()]//g') + +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 ) + print_results $lines fi print_foot |