Use bash function, not PowerShell

This commit is contained in:
Hiro Asari 2014-06-11 11:28:42 -04:00
parent c822efc94e
commit 851c2b2db2

View File

@ -1,25 +1,21 @@
#!/bin/bash #!/bin/bash
function travis_retry() { travis_retry() {
$Local:result = 0 local result=0
$Local:count = 1 local count=1
$Local:cmd_string = $args -join ' ' while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
while ( $count -le 3 ) { echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2
if ( $result -ne 0 ) {
Write-Host -foregroundColor Red "`nThe command ""$cmd_string"" failed. Retrying, $count of 3.`n" 2>&1
} }
Invoke-Expression($cmd_string) "$@"
$result = $LastExitCode result=$?
if ( $result -eq 0 ) { [ $result -eq 0 ] && break
break count=$(($count + 1))
}
$count=$count + 1
sleep 1 sleep 1
} done
if ( $count -eq 3 ) { [ $count -eq 3 ] && {
Write-Host -foregroundColor Red "`nThe command ""$cmd_string"" failed 3 times.`n" 2>&1 echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2
} }
return $result return $result