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
Raw Normal View History

2023-12-07 04:02:47 +03:00
# Retry command every 2 sec until it completes successfully.
# Usage: try <COMMAND>
2023-12-07 01:44:42 +03:00
function try() {
2023-12-07 04:02:47 +03:00
if [[ "${*}" = "" ]]; then
help try
return 2
fi
2023-12-05 21:50:45 +03:00
local result=-1
while [ "$result" != 0 ]; do
2023-12-07 04:02:47 +03:00
${*}
2023-12-05 21:50:45 +03:00
result=$?
if [ "$result" != 0 ]; then
sleep 2
fi
done
2023-08-08 16:24:15 +03:00
}
2023-10-23 03:31:00 +03:00
2023-10-24 17:26:22 +03:00
# autocomplete.
2023-10-23 03:31:00 +03:00
complete -F _autocomplete_nested try