"Ping Yin" [off-list ref] writes:
On Sat, Mar 1, 2008 at 3:29 PM, Junio C Hamano [off-list ref] wrote:
expr is portable?
It's not just portable but is a very old fashioned and time-proven way to
do things like this.
quoted
if summary_limit=$(( $2 + 0 )) 2>/dev/null ||
test "$2" != "$summary_limit"
then
usage
fi
summary_limit=$(( $2 + 0 )) will always has return status 0
Ah, there's a typo there. The intention was to reject non numbers
for two in 43 -32 'deadbeef' ' -27' HEAD ''
do
if sl=$(( $two + 0 )) 2>/dev/null && test "$two" == "$sl"
then
echo Ah, "$two", that is a number.
else
echo You gave me an un-number "'$two' (vs '$sl')".
fi
done