Re: [PATCH 05/15] kbuild: build init/built-in.a just once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 14, 2022 at 6:46 PM David Laight <David.Laight@xxxxxxxxxx> 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



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux