Skip to contentSkip to conversation

git_retry.sh: remove let, use arithmetic evaluation

PATCH New [email protected] 1 participant 1 message Mar 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git_retry.sh: remove let, use arithmetic evaluation

From: Randolph Sapp <[email protected]>

Since none of this script is checking the exit code of let, we can replace it with a standard arithmetic evaluation and switch the shebang to a POSIX shell.

According to bash(1) let simply performs an arithmetic evaluation with an additional check that returns 1 if the last arg evaluates to 0.

---
 git_retry.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
git_retry.sh +8 -8
index 1ffee7a..5683eef 100755
@@ -1,9 +1,9 @@
-#!/bin/bash
+#!/bin/sh
 
-let glMaxRetries=5
-let glCurrRetry=1
-let glDelay=15
-let glExitCode=0
+glMaxRetries=5
+glCurrRetry=1
+glDelay=15
+glExitCode=0
 
 while [ $glMaxRetries -ge $glCurrRetry ]; do
 
@@ -15,16 +15,16 @@ while [ $glMaxRetries -ge $glCurrRetry ]; do
         exit
     fi
 
-    let glSleep=$glDelay*$glCurrRetry
+    glSleep=$((glDelay*glCurrRetry))
 
-    let glRemainingRetries=$glMaxRetries-$glCurrRetry
+    glRemainingRetries=$((glMaxRetries-glCurrRetry))
 
     if [ $glRemainingRetries -gt 0 ]; then
         echo "git failed... remaining attempts: $glRemainingRetries    sleeping $glSleep seconds"
         sleep $glSleep
     fi
 
-    let glCurrRetry=$glCurrRetry+1
+    glCurrRetry=$((glCurrRetry+1))
 
 done
 
Signature · 1 line
2.49.0