scripts for my gemini capsule
ccel: redirect some errors
Zach DeCook 2021-04-10
parent 7888e96 · commit c7d0ca4
-rwxr-xr-xccel.sh2
-rwxr-xr-xccelauthor.sh10
2 files changed, 9 insertions, 3 deletions
diff --git a/ccel.sh b/ccel.sh
index 9b59c73..0670fa3 100755
--- a/ccel.sh
+++ b/ccel.sh
@@ -8,7 +8,7 @@ fi
hasslash=$(echo "$QUERY_STRING"|grep '/')
if [ "$hasslash" = "" ]
then
- printf "30 /cgi-bin/ccelauthor.sh?$QUERY_STRING\r\n"
+ printf "31 /cgi-bin/ccelauthor.sh?$QUERY_STRING\r\n"
exit 0
fi
printf "20 text/gemini\r\n"
diff --git a/ccelauthor.sh b/ccelauthor.sh
index ef3eb86..a383b68 100755
--- a/ccelauthor.sh
+++ b/ccelauthor.sh
@@ -4,6 +4,12 @@ then
printf "10 Enter a ccel author \r\n"
return
fi
-
+if (echo "$QUERY_STRING" | grep '?'>/dev/null)
+then
+ prefix="$(echo "$QUERY_STRING"|cut -d '?' -f1)"
+ # Permanent redirect. These URLs should never have been made.
+ printf "31 ccelauthor.sh?$prefix\r\n"
+ return
+fi
printf "20 text/gemini\r\n"
-curl https://ccel.org/index/author |grep "/$QUERY_STRING/" | sed 's@ccel/@\t@g' |sed 's/"/\t/g' |cut -f3 | sed 's/^/=> ccel.sh?/g'
+curl -q https://ccel.org/index/author 2>/dev/null|grep "/$QUERY_STRING/" | sed 's@ccel/@\t@g' |sed 's/"/\t/g' |cut -f3 | sed 's/^/=> ccel.sh?/g'