[Remind-Fans] New Remind helper script: remint - a Text UI for Remind

Dianne Skoll dianne at skoll.ca
Fri Sep 16 10:13:58 EDT 2022


On Fri, 16 Sep 2022 15:45:52 +0200
Mathieu via Remind-fans <remind-fans at lists.skoll.ca> wrote:

> > - Every time the ui function finishes some command other than 'q',
> > it calls itself again.

I also pointed this out to Mathieu.  These recursive calls consume
memory for each stack frame.

You could restructure ui so it looks something like this:

ui() {
     while true ; do
           page
           read -rsn1
           case $REPLY in
               "P" | "p" | ",")
                   REF=$(date -d "$REF-$SPAN $UNIT" "+%Y-%m-%d")
                   continue
                   ;;
           # ... etc
     done
}

In other words, wrap the main loop in an *actual* loop and replace
recursive calls to "ui" with "continue" to restart the loop from the
top.

Note that executing "ui" is not the same thing as "goto ui"; it's
more like "gosub ui" (to use BASIC references.)

Regards,

Dianne.


More information about the Remind-fans mailing list