Shell script programming : "bad number" error

I am writing a simple shell script and I am having a strange error about "bad number". Here is my code :

status=0
maxRetries=3
retryCount=1
while [[ status == 0 ]] || [[ retryCount -le  maxRetries ]]
do
    ....
    retryCount=$((retryCount+1))
done

As far as I see, I have properly declared maxRetries and retryCount as integers, so I don't see why it complains about bad number on the while statement. Anyone have an idea?

Upvotes: 1

Views: 14642

Answers (1)

kojiro
kojiro

Reputation: 77157

status, retryCount and maxRetries are strings, not numbers. You want to expand those parameters with the $ sigil. Alternatively, you could use arithmetic expressions, which do not require the sigil.

while (( status == 0 || retryCount < maxRetries ))

Upvotes: 2

Related Questions