Skip to content

Commit

Permalink
lib/omb-prompt-base(_omb_prompt_timeout): Check timeout commands on s…
Browse files Browse the repository at this point in the history
…tartup
  • Loading branch information
akinomyoga committed Oct 14, 2023
1 parent 4bd96e4 commit c886bf4
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions lib/omb-prompt-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c886bf4

Please sign in to comment.