(no title)
epr | 9 months ago
#!/usr/bin/env bash
long_fn () { # this can contain anything, like OPs until curl loop
sleep $1
}
# to TIMEOUT_DURATION BASH_FN_NAME BASH_FN_ARGS...
to () {
local duration="$1"; shift
local fn_name="$1"; shift
export -f "$fn_name"
timeout "$duration" bash -c "$fn_name"' "$@"' _ $@
}
time to 1s long_fn 5 # will report it ran 1 second
abbeyj|9 months ago
epr|9 months ago