fix prof-tail, still needs testing
authorIan Kelling <ian@iankelling.org>
Thu, 4 Dec 2025 18:51:04 +0000 (13:51 -0500)
committerIan Kelling <ian@iankelling.org>
Thu, 4 Dec 2025 18:51:04 +0000 (13:51 -0500)
filesystem/usr/local/bin/prof-tail

index 9a9c02488e8bd0ca62fab43a2c16bce6dd0ec4e7..c84d77a4765cfa0ebb1e457dc8e627210885dce2 100755 (executable)
@@ -51,6 +51,7 @@ xmpp_users=(
   jtuttle
 )
 
+
 pre="^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}-[0-9]{2} -"
 
 while true; do
@@ -58,6 +59,10 @@ while true; do
   secs_till_midnight=$(( midnight - EPOCHSECONDS ))
   log_today=$(date '+%Y_%m_%d').log
   logdir=/home/iank/.local/share/profanity/chatlogs/iank_at_fsf.org
+  user_logs=()
+  for u in ${xmpp_users[@]}; do
+    user_logs+=($logdir/${u}_at_fsf.org/$log_today)
+  done
 
   # example room chat log:
   #
@@ -66,7 +71,7 @@ while true; do
   # example pm chat log:
   #
   # 2025-11-02T16:29:27.100202-05 - me: ok. good luck
-# 2025-11-02T17:42:02.547790-05 - zoe@fsf.org: oh damn
+  # 2025-11-02T17:42:02.547790-05 - zoe@fsf.org: oh damn
 
   # psuedocode simplified strategy:
   # tail room_logs | grep -v '^pre iank:' | grep iank | tail - pm_logs | grep -v "^$pre me:"
@@ -74,7 +79,7 @@ while true; do
   timeout --foreground $secs_till_midnight tail -n0 -qF \
           $logdir/rooms/*/$log_today 2>/dev/null \
     | sed -rn "/$pre iank: /d;s/$pre /room: /;/\biank\b/p" \
-    | tail -n0 -qF -- - $(for u in ${xmpp_users[@]}; do echo $logdir/${u}_at_fsf.org/$log_today; done) 2>/dev/null \
+    | tail -n0 -qf --retry -- - ${user_logs[@]} \
     | sed -rn "s/$pre ([^@:]+)@.*/pm: \1/p;/^room: /p" || [[ ${PIPESTATUS[0]} == 124 ]]
   # note: man timeout says 124 is when timeout times out.