diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index 902d1db7d..e95602f72 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -110,24 +110,23 @@ function _omb_prompt_git { } function _omb_prompt_timeout { - # Runs the given command with the given timeout - # $1 Timeout in seconds - # $@ Command to be executed. - local TIME=$1 - shift - local CMD=$@ - local TIMEOUT= - if which timeout &> /dev/null; then - TIMEOUT=timeout - elif which gtimeout &> /dev/null; then - TIMEOUT=gtimeout - fi - - if [ -z "$TIMEOUT" ]; then - ${CMD} - else - $TIMEOUT ${TIME} ${CMD} - fi + # Runs the given command with the given timeout + # $1 Timeout in seconds + # $@ Command to be executed. + local time=$1 + shift + local timeout= + if _omb_util_command_exists timeout; then + timeout=timeout + elif _omb_util_command_exists gtimeout; then + timeout=gtimeout + fi + + if [[ ! $timeout ]]; then + "$@" + else + "$timeout" "$time" "$@" + fi } function scm {