]> git.armaanb.net Git - bin.git/commitdiff
scoop-cgi: make more bug resistant
authorArmaan Bhojwani <me@armaanb.net>
Wed, 2 Jun 2021 00:26:10 +0000 (20:26 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Wed, 2 Jun 2021 00:26:10 +0000 (20:26 -0400)
scoop-cgi

index b7531ecb7df6192252ccb70709ccb01f9040593d..8f56f3e37790bf4459fd09b6fbbb886ccead4af1 100755 (executable)
--- a/scoop-cgi
+++ b/scoop-cgi
@@ -28,14 +28,16 @@ fi
 channel=$(grep -x "$channel" /etc/scoop-cgi/channels)
 if [ -z "$channel" ]; then
                echo "Status: 404"
-               echo "Content-type: text/plain\n"
+               printf "Content-type: text/plain\n\n"
                echo "404. Channel not logged."
                exit 0
 fi
 
 time=$(echo "$PATH_INFO" | awk -F / '{print $3}' | xargs date -I -d)
+today=$(date -I)
+time=${time:-$today}
 db=$(cat /etc/scoop-cgi/database)
 
-echo "Content-type: text/plain\n"
-scoop -d "$db" -p "$channel" -D "${time:-now}" -F "%Y-%m-%d %H:%M:%S" \
+printf "Content-type: text/plain\n\n"
+PAGER=/dev/tty scoop -d "$db" -p "$channel" -D "$time" -F "%Y-%m-%d %H:%M:%S" \
                | awk '{$1=""; print substr($0, 2, length($0) - 1)}'