lkml.org 
[lkml]   [2022]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 05/15] kbuild: build init/built-in.a just once
On Wed, Sep 14, 2022 at 6:46 PM David Laight <David.Laight@aculab.com> wrote:
>
> ...
> > > +VERSION=$(cat .version) 2>/dev/null &&
> > > +VERSION=$(expr $VERSION + 1) 2>/dev/null ||
> > > +VERSION=1
>
> What's wrong with:
> VERSION=$(($(cat .version 2>/dev/null) + 1))


One reason was, the original code used 'expr'.



> If you are worried about .version not containing a valid
> number and $((...)) failing then use ${VERSION:-1} later.


Maybe another reason is,
I want to make the behavior deterministic when
the .version file contains a non-integer string.




$ unset FOO
$ echo FOO > .version
$ echo $(($(cat .version 2>/dev/null) + 1))
1


$ export FOO=100
$ echo FOO > .version
$ echo $(($(cat .version 2>/dev/null) + 1))
101




I want the script to consistently return 1
whether or not 'FOO' is available in the user's environment.






> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)
>


--
Best Regards
Masahiro Yamada

\
 
 \ /
  Last update: 2022-09-14 15:02    [W:0.077 / U:1.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site