From: Junio C Hamano Date: Sat, 01 Mar 2008 20:26:14 GMT Subject: Re: [PATCH v2 3/3] git-submodule: New subcommand 'summary' (3) - limit summary size Message-ID: <7vpruexkbd.fsf@gitster.siamese.dyndns.org> In-Reply-To: <46dff0320803010442y12c1326dk45f53ce17453b53c@mail.gmail.com> "Ping Yin" writes: > On Sat, Mar 1, 2008 at 3:29 PM, Junio C Hamano wrote: > > expr is portable? It's not just portable but is a very old fashioned and time-proven way to do things like this. >> 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