From 9cd5703751976f77fd6e2b24ffb90c4b9998ed9e Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sat, 14 Oct 2023 17:39:57 +0900 Subject: [PATCH] lib/omb-prompt-base(_omb_prompt_timeout): Check timeout commands on startup --- lib/omb-prompt-base.sh | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) 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