0
0
mirror of https://github.com/thegeeklab/retry.git synced 2024-11-25 08:40:39 +00:00

getopt location as a environment variable (to support mac/homebrew craziness)

This commit is contained in:
Neville Kadwa 2018-04-30 16:56:14 -04:00
parent 7dfebe7751
commit 91e25f3daf

7
retry
View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
GETOPT_BIN=$IN_GETOPT_BIN
GETOPT_BIN=${GETOPT_BIN:-getopt}
__sleep_amount() { __sleep_amount() {
if [ -n "$constant_sleep" ]; then if [ -n "$constant_sleep" ]; then
sleep_time=$constant_sleep sleep_time=$constant_sleep
@ -93,7 +96,7 @@ EOF
exit 0 exit 0
fi fi
getopt --test > /dev/null $GETOPT_BIN --test > /dev/null
if [[ $? -ne 4 ]]; then if [[ $? -ne 4 ]]; then
echo "Im sorry, 'getopt --test' failed in this environment. Please load GNU getopt." echo "Im sorry, 'getopt --test' failed in this environment. Please load GNU getopt."
exit 1 exit 1
@ -102,7 +105,7 @@ EOF
OPTIONS=vt:s:m:x:f: OPTIONS=vt:s:m:x:f:
LONGOPTIONS=verbose,tries:,sleep:,min:,max:,fail: LONGOPTIONS=verbose,tries:,sleep:,min:,max:,fail:
PARSED=$(getopt --options="$OPTIONS" --longoptions="$LONGOPTIONS" --name "$0" -- "$@") PARSED=$($GETOPT_BIN --options="$OPTIONS" --longoptions="$LONGOPTIONS" --name "$0" -- "$@")
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
# e.g. $? == 1 # e.g. $? == 1
# then getopt has complained about wrong arguments to stdout # then getopt has complained about wrong arguments to stdout