simple-optimism-node icon indicating copy to clipboard operation
simple-optimism-node copied to clipboard

progress.sh: Avoid accidental early return

Open karlb opened this issue 1 year ago • 0 comments
trafficstars

expr returns a non-zero exit code if its calculated value is zero. This is surprising and usually not what you want. In this case, it will lead to the script terminating early for some values (e.g. HOURS=0). Small example to show the problem:

> bash -c 'HOURS=`expr 0` && echo true || echo false'
false

Fortunately, bash has the arithmetic calculation syntax $((...)) that behaves as intended.

karlb avatar Nov 12 '24 15:11 karlb