fix multiline calendar entries master
authormirabilos <m@mirbsd.org>
Wed, 10 Nov 2021 23:07:34 +0000 (00:07 +0100)
committermirabilos <mirabilos@evolvis.org>
Wed, 10 Nov 2021 23:07:34 +0000 (00:07 +0100)
mksh/profile-funcs

index cf630b8..bf26e9a 100644 (file)
@@ -27,10 +27,15 @@ function showweather {
 # show appointments
 function showtermine {
        [[ -s ~/.etc/Termine ]] || return 0
-       LC_ALL=C.UTF-8 calendar -f ~/.etc/Termine | while IFS=' ' read a b; do
-               typeset -L8 a
-               b=$(fold -sw 70 <<<"$b")
-               print -r -- "‣ $a${b//$'\n'/$'\n\t  '}"
+       LC_ALL=C.UTF-8 calendar -f ~/.etc/Termine | while IFS= read -r line; do
+               if [[ $line != *$'\t'* ]]; then
+                       print -r -- "‣ $line"
+                       continue
+               fi
+               set -U
+               typeset -L8 a=${line%%$'\t'*}
+               line=$(fold -sw 70 <<<"${line#*$'\t'}")
+               print -r -- "‣ $a${line//$'\n'/$'\n\t  '}"
        done
        LC_ALL=C.UTF-8 date +'⇒ %b %e  %Y, %H:%M:%S%z (%Z), %G-W%V-%u (%a) ⇐'
 }