https://cr.yp.to/daemontools.html
Here is a bash function that retries N times:
retry() {
local n=$1
shift
for i in $(seq $n); do
"$@"
done
}
retry 5 echo hi
Then you can compose with a timeout function, which already exists: timeout-demo() {
timeout 0.1 $0 retry 5 echo hi
}
You can pass the names of other functions as pre and post hooks as well.https://www.gnu.org/software/coreutils/manual/html_node/time...
Shell has a very forth-like quality to it, and Forth is sort of like a backwards Lisp as well (postfix rather than prefix).