simple-optimism-node
simple-optimism-node copied to clipboard
progress.sh: Avoid accidental early return
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.