I’m checking a counter in a loop to determine if it’s larger than some maximum, if specified in an optional parameter. Since it’s optional, I can either default the maximum to a special value or to the maximum possible integer. The first option would require an extra check at each iteration, so I’d like to instead find out what is the maximum integer that will work with the -gt Bourne Shell operation.
I’m checking a counter in a loop to determine if it’s larger than some
Share
I’d stay clear of integer limits as they’re non portable and problematic
Instead I’d just do as you suggest and do the extra comparison like: