dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

retry.sh (660B)


      1 # Copied retry logic from Travis CI [http://bit.ly/2jPDCtV]
      2 # Author: gonewest818 https://github.com/clojure-emacs/cider/pull/2139
      3 
      4 ANSI_RED="\033[31;1m"
      5 ANSI_GREEN="\033[32;1m"
      6 ANSI_RESET="\033[0m"
      7 ANSI_CLEAR="\033[0K"
      8 
      9 travis_retry() {
     10   local result=0
     11   local count=1
     12   while [ $count -le 3 ]; do
     13     [ $result -ne 0 ] && {
     14       echo -e "\n${ANSI_RED}The command \"$@\" failed. Retrying, $count of 3.${ANSI_RESET}\n" >&2
     15     }
     16     "$@"
     17     result=$?
     18     [ $result -eq 0 ] && break
     19     count=$(($count + 1))
     20     sleep 1
     21   done
     22 
     23   [ $count -gt 3 ] && {
     24     echo -e "\n${ANSI_RED}The command \"$@\" failed 3 times.${ANSI_RESET}\n" >&2
     25   }
     26 
     27   return $result
     28 }