From owner-freebsd-stable@FreeBSD.ORG Fri Sep 21 17:46:17 2012 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5F5E5106564A for ; Fri, 21 Sep 2012 17:46:17 +0000 (UTC) (envelope-from david@catwhisker.org) Received: from albert.catwhisker.org (m209-73.dsl.rawbw.com [198.144.209.73]) by mx1.freebsd.org (Postfix) with ESMTP id 364E58FC0C for ; Fri, 21 Sep 2012 17:46:16 +0000 (UTC) Received: from albert.catwhisker.org (localhost [127.0.0.1]) by albert.catwhisker.org (8.14.5/8.14.5) with ESMTP id q8LHkF5X029605; Fri, 21 Sep 2012 10:46:15 -0700 (PDT) (envelope-from david@albert.catwhisker.org) Received: (from david@localhost) by albert.catwhisker.org (8.14.5/8.14.5/Submit) id q8LHkFe2029604; Fri, 21 Sep 2012 10:46:15 -0700 (PDT) (envelope-from david) Date: Fri, 21 Sep 2012 10:46:15 -0700 From: David Wolfskill To: Jilles Tjoelker Message-ID: <20120921174615.GF28959@albert.catwhisker.org> References: <20120921170902.GC28959@albert.catwhisker.org> <20120921173406.GC9070@stack.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5Mfx4RzfBqgnTE/w" Content-Disposition: inline In-Reply-To: <20120921173406.GC9070@stack.nl> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: stable@freebsd.org Subject: Re: /bin/sh arithmetic doesn't seem to like leading 0 now X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2012 17:46:17 -0000 --5Mfx4RzfBqgnTE/w Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 21, 2012 at 07:34:06PM +0200, Jilles Tjoelker wrote: > ... > > Is this intentional? >=20 > Yes, it was changed with r216547, December 2010. >=20 > 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 to 3. Ah; OK. > There are indeed various cases where this inconsistency does not matter > (because the numbers with leading zeroes do not exceed 10). Sure. Especially when working with "month numbers". :-} > > (I can work around it -- e.g., by using sed to strip leading 0 from the > > month number (since strftime() doesn't appear to have a format that > > provides the value in a form that lacks the leading zero for values < > > 10). But I'd rather not do that if I don't need to.) >=20 > You can use date +%-m although it is not in POSIX. Ah -- I see that now ("%-* GNU libc extension....") > With POSIX only, it is still possible to do it reasonably efficiently, > for example $(( 1$(date +%m) - 100 )) or v=3D$(date +%m); v=3D${v#0}. > ... Thanks. Peace, david --=20 David H. Wolfskill david@catwhisker.org Depriving a girl or boy of an opportunity for education is evil. See http://www.catwhisker.org/~david/publickey.gpg for my public key. --5Mfx4RzfBqgnTE/w Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlBcp+cACgkQmprOCmdXAD0BiwCdFJ84BLv3FoygcebDVIWKyiMP +r8AnjfDOOYTGQMzh/y8cozAfge9nufe =vvx3 -----END PGP SIGNATURE----- --5Mfx4RzfBqgnTE/w--