summaryrefslogtreecommitdiff
path: root/search_cgi
diff options
context:
space:
mode:
Diffstat (limited to 'search_cgi')
-rwxr-xr-xsearch_cgi33
1 files changed, 22 insertions, 11 deletions
diff --git a/search_cgi b/search_cgi
index b6dccfe..5302e3a 100755
--- a/search_cgi
+++ b/search_cgi
@@ -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