]> git.plutz.net Git - serve0/commitdiff
quicker discard of unpaged items
authorPaul Hänsch <paul@plutz.net>
Mon, 24 Apr 2023 18:14:24 +0000 (20:14 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 24 Apr 2023 18:14:24 +0000 (20:14 +0200)
list.sh

diff --git a/list.sh b/list.sh
index dd5c83d4a44989e69e23ee17e57c524adb9c2c03..8df5b6ea4c3cfa9228de058aab491adf11cbed9a 100755 (executable)
--- a/list.sh
+++ b/list.sh
@@ -160,13 +160,15 @@ list_paginate() {
 
   printf '[div .itemlist '
   while :; do
-    c=$((c + 1))
-    if [ $c -gt $page -a $c -le $end  ]; then 
+    if [ $c -lt $page ]; then
+      read -r discard || break
+    elif [ $c -ge $end ]; then
+      c=$((c + $(wc -l) ))
+    else
       read_meta || break
       list_item
-    else
-      read -r discard || break
     fi
+    c=$((c + 1))
   done
   printf ']'