Skip to content

Commit

Permalink
lib/omb-prompt-base(_omb_prompt_timeout): Fix coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Oct 14, 2023
1 parent fb47077 commit db302de
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions lib/omb-prompt-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,27 @@ function _omb_prompt_format {
}

function _omb_prompt_git {
_omb_prompt_timeout $SCM_GIT_TIMEOUT command 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 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 {
Expand Down

0 comments on commit db302de

Please sign in to comment.