From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Tue, 25 Jun 2013 12:07:21 -0600 Subject: [U-Boot] [PATCH V2 1/9] Validate dtc is new enough In-Reply-To: <20130625172257.GP24305@book.gsilab.sittig.org> References: <1372088629-14134-1-git-send-email-swarren@wwwdotorg.org> <1372088629-14134-2-git-send-email-swarren@wwwdotorg.org> <20130625172257.GP24305@book.gsilab.sittig.org> Message-ID: <51C9DC59.9020505@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/25/2013 11:22 AM, Gerhard Sittig wrote: > On Mon, Jun 24, 2013 at 09:43 -0600, Stephen Warren wrote: >> >> +checkdtc: >> + @if test $(call dtc-version) -lt 0104; then \ >> + echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \ >> + false; \ >> + fi > > ... and ... > >> --- /dev/null >> +++ b/tools/dtc-version.sh >> @@ -0,0 +1,20 @@ >> +#!/bin/sh >> +# >> +# dtc-version dtc-command >> +# >> +# Prints the dtc version of `dtc-command' in a canonical 4-digit form >> +# such as `0222' for binutils 2.22 >> +# > > So the numbers get converted to something that's neatly aligned > and free of whitespace and can get sorted alphabetically. > > But the numbers get passed to $SHELL and the builtin test(1) > command, and get compared numerically ('-lt' operator). > > Does that mean that the test break with digits beyond seven, when > numbers no longer can get interpreted as valid octal numbers? I'm pretty sure sh treats the numbers as decimal. Testing appears to support this: [swarren at swarren-lx1 kernel.git]$ if [ 0104 -lt 0104 ]; then echo yes; else echo no; fi no [swarren at swarren-lx1 kernel.git]$ if [ 0103 -lt 0104 ]; then echo yes; else echo no; fi yes [swarren at swarren-lx1 kernel.git]$ if [ 0803 -lt 0104 ]; then echo yes; else echo no; fi no [swarren at swarren-lx1 kernel.git]$ if [ 0802 -lt 0804 ]; then echo yes; else echo no; fi yes [swarren at swarren-lx1 kernel.git]$ if [ 0804 -lt 0804 ]; then echo yes; else echo no; fi no [swarren at swarren-lx1 kernel.git]$ if [ 0806 -lt 0804 ]; then echo yes; else echo no; fi no