File retry-1655407786.7ff7de5.obscpio of Package retry
07070100000000000041FD00000000000000000000000162AB84AA00000000000000000000000000000000000000000000002100000000retry-1655407786.7ff7de5/.github07070100000001000041FD00000000000000000000000162AB84AA00000000000000000000000000000000000000000000002B00000000retry-1655407786.7ff7de5/.github/workflows07070100000002000081B400000000000000000000000162AB84AA000001CA000000000000000000000000000000000000003200000000retry-1655407786.7ff7de5/.github/workflows/ci.yml---
name: ci
# yamllint disable-line rule:truthy
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: unit tests
run: |
make test-unit
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Static checks
run: |
sudo apt-get install shellcheck
export PATH=.:$PATH
make checkbashisms checkstyle
07070100000003000081B400000000000000000000000162AB84AA00000020000000000000000000000000000000000000002400000000retry-1655407786.7ff7de5/.gitignore/test-more-bash/
/checkbashisms
07070100000004000081B400000000000000000000000162AB84AA0000027C000000000000000000000000000000000000002600000000retry-1655407786.7ff7de5/.mergify.yml---
pull_request_rules:
- name: automatic merge
conditions:
- and: &base_checks
- base=main
- -label~=^acceptance-tests-needed|not-ready
- "status-success~=test"
- "status-success~=style"
- and:
- "#approved-reviews-by>=1"
- "#changes-requested-reviews-by=0"
# https://doc.mergify.io/examples.html#require-all-requested-reviews-to-be-approved
- "#review-requested=0"
actions: &merge
merge:
method: merge
- name: automatic merge on special label
conditions:
- and: *base_checks
- "label=merge-fast"
actions: *merge
07070100000005000081B400000000000000000000000162AB84AA00000436000000000000000000000000000000000000002100000000retry-1655407786.7ff7de5/LICENSEMIT License
Copyright Oliver Kurz
Copyright SUSE LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
07070100000006000081B400000000000000000000000162AB84AA000005C8000000000000000000000000000000000000002200000000retry-1655407786.7ff7de5/Makefile.PHONY: all
all:
.PHONY: test
test: checkstyle test-unit
.PHONY: test-unit
test-unit: test-more-bash
@command -v prove >/dev/null 2>&1 || echo "Command 'git' not found, can not get test-more-bash to execute tests"
prove -r test/
test-more-bash:
@command -v git >/dev/null 2>&1 || echo "Command 'git' not found, can not get test-more-bash to execute tests"
git clone https://github.com/ingydotnet/test-more-bash.git --depth 1 -b 0.0.5
checkbashisms:
@command -v wget >/dev/null 2>&1 || echo "Command 'wget' not found, can not download checkbashisms"
wget -q https://salsa.debian.org/debian/devscripts/-/raw/master/scripts/checkbashisms.pl -O checkbashisms
chmod +x checkbashisms
command -v checkbashisms >/dev/null || echo "Downloaded checkbashisms. You can check the file and add to PATH, then call make again"
.PHONY: checkstyle
checkstyle: test-shellcheck test-checkbashisms
.PHONY: test-shellcheck
test-shellcheck:
@command -v shellcheck >/dev/null 2>&1 || echo "Command 'shellcheck' not found, can not execute shell script checks"
shellcheck -x $$(file --mime-type * | sed -n 's/^\(.*\):.*text\/x-shellscript.*$$/\1/p')
.PHONY: test-checkbashisms
test-checkbashisms:
@command -v checkbashisms >/dev/null 2>&1 || echo "Command 'checkbashisms' not found, can not execute shell script checks"
checkbashisms -x $$(file --mime-type * | sed -n 's/^\(.*\):.*text\/x-shellscript.*$$/\1/p')
.PHONY: install
install:
install -m 755 retry "$(DESTDIR)"/usr/bin/retry
07070100000007000081B400000000000000000000000162AB84AA000006C7000000000000000000000000000000000000002300000000retry-1655407786.7ff7de5/README.md# retry 
A simply retry tool in plain POSIX sh.
## How to use
Simply call
```
retry $cmd
```
to execute `$cmd` and on failure retry multiple times with some waiting time
between calls. Multiple command line parameters exist to tweak execution.
It is possible to specify no waiting time if desired:
```
retry -s 0 $cmd
```
If it is necessary to specify command line parameters to `$cmd` separate the
arguments with `--` like this:
```
retry -- $cmd --my-argument -X 3
```
Often it is desired to command the execution with a timeout. This can be done
with the `timeout` command from [GNU
coreutils](https://www.gnu.org/software/coreutils/) already present on many
systems. Either use with a global timeout:
```
timeout 10 retry $cmd
```
to execute `$cmd` with retrying but only wait up to 10s in total. Or with a
timeout per execution:
```
retry -- timeout 10 $cmd
```
## Contribute
This project lives in https://github.com/okurz/retry
Feel free to add issues in github or send pull requests.
### Rules for commits
* For git commit messages use the rules stated on
[How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/) as
a reference
If this is too much hassle for you feel free to provide incomplete pull
requests for consideration or create an issue with a code change proposal.
### Local testing
#### Functional testing
This is done with the [Test::More bash
library](https://github.com/ingydotnet/test-more-bash).
It will be automatically cloned.
To execute tests call
```
make test
```
#### Style checks
```
make checkstyle
```
## License
This project is licensed under the MIT license, see LICENSE file for details.
07070100000008000041FD00000000000000000000000162AB84AA00000000000000000000000000000000000000000000001E00000000retry-1655407786.7ff7de5/dist07070100000009000041FD00000000000000000000000162AB84AA00000000000000000000000000000000000000000000002200000000retry-1655407786.7ff7de5/dist/rpm0707010000000A000081B400000000000000000000000162AB84AA000004AC000000000000000000000000000000000000002D00000000retry-1655407786.7ff7de5/dist/rpm/retry.spec#
# spec file for package retry
#
# Copyright SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
Name: retry
Version: 1
Release: 0
Summary: A simple tool for retrying command executions in plain POSIX sh
License: MIT
Group: Development/Tools/Other
BuildArch: noarch
Url: https://github.com/okurz/retry
Source0: %{name}-%{version}.tar.xz
%description
A simple tool for retrying command executions in plain POSIX sh.
%prep
%setup -q
%build
%install
mkdir -p %{buildroot}%{_bindir}
%make_install
%check
%files
%{_bindir}/retry
%changelog
0707010000000B000081FD00000000000000000000000162AB84AA0000059F000000000000000000000000000000000000001F00000000retry-1655407786.7ff7de5/retry#!/bin/sh -e
usage() {
echo "usage: $0 [options] [cmd...]
options:
-h,--help Show this help
-r,--retries=RETRIES How many retries to do on command failure after
the initial try. Defaults to 3.
-s,--sleep=SLEEP How many seconds to sleep between retries.
Defaults to 3 seconds.
-e,--exponential[=FACTOR] Enable simple exponential back-off algorithm.
Disabled by default, factor defaults to 2
(binary exponential back-off).
"
exit "$1"
}
# parse arguments
opts=$(getopt \
--options h,r:,s:,e:: \
--longoptions help,retries:,sleep:,exponential:: \
--name "$(basename "$0")" -- "$@") || usage 1
eval set -- "$opts"
while [ $# -gt 0 ]; do
case "$1" in
-h | --help ) usage 0; shift ;;
-r | --retries ) retries=$2; shift 2 ;;
-s | --sleep ) sleep=$2; shift 2 ;;
-e | --exponential ) exponential=${2:-2}; shift 2 ;;
-- ) shift; break ;;
* ) break ;;
esac
done
retries="${retries:-3}"
sleep="${sleep:-3}"
until "$@"; do
[ "$retries" -gt 0 ] || break
echo "Retrying up to $retries more times after sleeping ${sleep}s …" >&2
retries=$((retries-1))
sleep "$sleep"
[ -n "$exponential" ] && sleep=$((sleep*exponential))
done
[ $retries -gt 0 ]
0707010000000C000041FD00000000000000000000000162AB84AA00000000000000000000000000000000000000000000001E00000000retry-1655407786.7ff7de5/test0707010000000D000081FD00000000000000000000000162AB84AA000004FA000000000000000000000000000000000000002900000000retry-1655407786.7ff7de5/test/01-retry.t#!/usr/bin/env bash
set -e
dir=$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)
TEST_MORE_PATH=$dir/../test-more-bash
BASHLIB="`
find $TEST_MORE_PATH -type d |
grep -E '/(bin|lib)$' |
xargs -n1 printf "%s:"`"
PATH=$BASHLIB$PATH
source bash+ :std
use Test::More
plan tests 12
PATH=$dir/..:$PATH
sleep() { :;}
export -f sleep
ok "$(retry)" 'retry without parameter is ok'
like "$(retry --help)" usage: 'retry help is shown'
ok $? 'calling help returns success'
set +e; out=$(retry --unknown-option 2>&1); rc=$?; set -e
is $rc 1 'calling with unknown option returns failure'
like "$out" 'unrecognized option.*usage:' 'retry help is shown for unknown option'
ok "$(retry true)" 'successful command returns success'
is "$(retry true)" '' 'successful command does not show any output by default'
set +e; out=$(retry false 2>&1); rc=$?; set -e
like "$out" 'Retrying up to 3 more.*Retrying up to 1' 'failing command retries'
is $rc 1 'failing command returns no success'
set +e; out=$(retry -s 1 -e -r 2 false 2>&1); rc=$?; set -e
like "$out" 'sleeping 1s.*sleeping 2s' 'sleep amount doubles'
is $rc 1 'failing command returns no success'
set +e; out=$(retry -r 1 -- sh -c 'echo -n .; false' 2>/dev/null); set -e
is "$out" '..' 'specified number of tries (1+retries)'
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!23 blocks