Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-23 Thread Jilles Tjoelker
On Fri, Sep 21, 2012 at 10:26:37PM +, David O'Brien wrote: On Fri, Sep 21, 2012 at 07:34:06PM +0200, Jilles Tjoelker wrote: On Fri, Sep 21, 2012 at 10:09:02AM -0700, David Wolfskill wrote: $ echo $(( ( $( date +%m ) - 1 ) / 3 + 1 )) arithmetic expression: expecting ')': ( 09 - 1 ) /

/bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread David Wolfskill
I have a construct in a shell script that I had been using under stable/8 (most recently, @r240259), but which throws an error under stable/9 (at least as early as @r238602): $ echo $(( ( $( date +%m ) - 1 ) / 3 + 1 )) 3 $ uname -r 8.3-PRERELEASE $ echo $(( ( $( date +%m ) - 1 ) / 3 + 1 ))

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread Brandon Allbery
On Fri, Sep 21, 2012 at 1:09 PM, David Wolfskill da...@catwhisker.orgwrote: $ echo $(( 09 + 0 )) Unable to get to fbsd box now but suspicious mind wants to know what happens with 07 in place of 09. -- brandon s allbery allber...@gmail.com wandering unix

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread David Wolfskill
On Fri, Sep 21, 2012 at 01:20:07PM -0400, Brandon Allbery wrote: On Fri, Sep 21, 2012 at 1:09 PM, David Wolfskill da...@catwhisker.orgwrote: $ echo $(( 09 + 0 )) Unable to get to fbsd box now but suspicious mind wants to know what happens with 07 in place of 09. As (I) expected, it's

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread Jilles Tjoelker
On Fri, Sep 21, 2012 at 10:09:02AM -0700, David Wolfskill wrote: I have a construct in a shell script that I had been using under stable/8 (most recently, @r240259), but which throws an error under stable/9 (at least as early as @r238602): $ echo $(( ( $( date +%m ) - 1 ) / 3 + 1 )) 3 $

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread David Wolfskill
On Fri, Sep 21, 2012 at 07:34:06PM +0200, Jilles Tjoelker wrote: ... Is this intentional? Yes, it was changed with r216547, December 2010. This was done to avoid an inconsistency where constants starting with 0 and containing 8 or 9 were decimal, so something like $((018-017)) expanded

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread Daryl Richards
On 21/09/2012 1:20 PM, Brandon Allbery wrote: On Fri, Sep 21, 2012 at 1:09 PM, David Wolfskill da...@catwhisker.orgwrote: $ echo $(( 09 + 0 )) Unable to get to fbsd box now but suspicious mind wants to know what happens with 07 in place of 09. Interestingly enough, bash gives a proper

Re: /bin/sh arithmetic doesn't seem to like leading 0 now

2012-09-21 Thread David O'Brien
On Fri, Sep 21, 2012 at 07:34:06PM +0200, Jilles Tjoelker wrote: On Fri, Sep 21, 2012 at 10:09:02AM -0700, David Wolfskill wrote: $ echo $(( ( $( date +%m ) - 1 ) / 3 + 1 )) arithmetic expression: expecting ')': ( 09 - 1 ) / 3 + 1 ... This was done to avoid an inconsistency where constants