travis: Use (( in travis_retry

If we use [, the script exits when a condition is false (as we use
set -e).
This commit is contained in:
Florian Bruhin 2016-05-12 08:08:19 +02:00
parent cdc79339fb
commit 3033f77f99

View File

@ -18,25 +18,26 @@
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# Stolen from https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
# and adjusted to use ((...))
travis_retry() {
local ANSI_RED="\033[31;1m"
local ANSI_RESET="\033[0m"
local result=0
local count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
while (( count < 3 )); do
if (( result != 0 )); then
echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
}
fi
"$@"
result=$?
[ $result -eq 0 ] && break
(( result == 0 )) && break
count=$(($count + 1))
sleep 1
done
[ $count -gt 3 ] && {
if (( count > 3 )); then
echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
}
fi
return $result
}