thbkrkr
2/19/2017 - 10:36 AM

wait_until.sh

#!/bin/bash -eu

until_ready() {
  declare try=${1:-10} sleepTime=${2:-1}
  _is_ready() {
    test $try -eq 0
    is_ready
  }
  until _is_ready ; do
    echo "try $try"
    sleep $sleepTime
    let try-=1
  done
}

is_ready() {
  test -f top
}

until_ready 20 0.2

echo "ok"