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 4bd96e4
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions lib/omb-prompt-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4bd96e4

Please sign in to comment.