]> git.lizzy.rs Git - rust.git/blob - src/ci/shared.sh
rustdoc: Hide `self: Box<Self>` in list of deref methods
[rust.git] / src / ci / shared.sh
1 #!/bin/false
2 # Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3 # file at the top-level directory of this distribution and at
4 # http://rust-lang.org/COPYRIGHT.
5 #
6 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9 # option. This file may not be copied, modified, or distributed
10 # except according to those terms.
11
12 # This file is intended to be sourced with `. shared.sh` or
13 # `source shared.sh`, hence the invalid shebang and not being
14 # marked as an executable file in git.
15
16 # See http://unix.stackexchange.com/questions/82598
17 function retry {
18   echo "Attempting with retry:" "$@"
19   local n=1
20   local max=5
21   while true; do
22     "$@" && break || {
23       if [[ $n -lt $max ]]; then
24         ((n++))
25         echo "Command failed. Attempt $n/$max:"
26       else
27         echo "The command has failed after $n attempts."
28         exit 1
29       fi
30     }
31   done
32 }