summaryrefslogtreecommitdiff
path: root/archive/lib/try.sh
blob: dc224caec59556c97ff8d70f3daf2872a983c3cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

. "$HOME/src/dotfiles/lib-src/tputfs.sh"

zero () {
    local cmd="$*"
    while ! (output="$($cmd)" ; echo "$output" ; [ -z "$output" ]); do
        status "executing '$cmd' produced output"
        status but it should produce no output -- spawning a shell
        status "when you C-d, I will attempt to run '$cmd' again"
        eval "$SHELL"
    done
}

try () {
    local cmd="$*"
    while ! $cmd; do
        status "executing '$cmd' failed: spawning a shell"
        status "when you C-d, I will attempt to run '$cmd' again"
        eval "$SHELL"
    done
}