This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Try.sh

22 lines
332 B
Bash

# Retry command every 2 sec until it completes successfully.
# Usage: try <COMMAND>
function try() {
if [[ "${*}" = "" ]]; then
help try
return 2
fi
local result=-1
while [ "$result" != 0 ]; do
${*}
result=$?
if [ "$result" != 0 ]; then
sleep 2
fi
done
}
# autocomplete.
complete -F _autocomplete_nested try