Skip to content

loop.sh

Timothée Mazzucotelli edited this page Aug 30, 2018 · 6 revisions

loop.sh

Control the loops within your scripts (pause/stop them).

Description

The loop.sh library provides functions to control loops within shells scripts. When used, it allows to control the execution of already running loops from whatever location or terminal. It is therefore possible to pause a script from another terminal without hitting Control-Z in the shell process running the script.

This execution control mechanism can even allow to control several loops and inner loops (nested loops) at the same time, or make different scripts dependents on each other.

Examples

  • In a script:

    #!/bin/bash
    source $(shellm-core-path)
    shellm-source shellm/loop
    
    loop init "script.loop"
    
    i=0
    while true; do
    
      loop control "script.loop"
    
      echo "$i"
      (( i++ ))
      sleep 1
    done
  • Then, from another terminal:

    $ loop pause "script.loop"
    $ loop resume "script.loop"
    $ loop stop "script.loop"

Scripts

Libraries

Clone this wiki locally