diff --git a/lib/omb-prompt-base.sh b/lib/omb-prompt-base.sh index 290e3cfd1..84a42df0a 100644 --- a/lib/omb-prompt-base.sh +++ b/lib/omb-prompt-base.sh @@ -109,25 +109,23 @@ function _omb_prompt_git { _omb_prompt_timeout "$SCM_GIT_TIMEOUT" command 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 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 -} +## @fn _omb_prompt_timeout +## Runs the given command with the given timeout +## @param $1 Timeout in seconds +## @param $@ Command to be executed. +if _omb_util_command_exists timeout; then + function _omb_prompt_timeout { + timeout "$@" + } +elif _omb_util_command_exists gtimeout; then + function _omb_prompt_timeout { + gtimeout "$@" + } +else + function _omb_prompt_timeout { + "${@:2}" + } +fi function scm { if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE