Re: [kbuild-all] Re: [PATCH] gcov: fail build on gcov_info size mismatch

From: Rong Chen
Date: Sun Mar 14 2021 - 22:33:33 EST




On 3/13/21 1:52 AM, Linus Torvalds wrote:
On Thu, Mar 11, 2021 at 7:50 PM Rong Chen <rong.a.chen@xxxxxxxxx> wrote:

The issue is from a=!, and [ "$a $b" = ".size .LPBX0," ] can avoid the
error.

+ [ ! = .size -a ABI = .LPBX0, ]
./kernel/gcov/geninfosize.sh: 13: [: =: unexpected operator
But that's not what the patch did.

The patch used quotes around $a, so "$a" should still be fine.

See:

[torvalds@ryzen ~]$ a="!" [ "$a" = ".size" ]

is fine, but

[torvalds@ryzen ~]$ a="!" [ $a = ".size" ]
-bash: [: =: unary operator expected

and the patch I saw, and that the test robot replied to, had that
correct quoting, afaik.

So I still don't see what the test robot is complaining about. Was
there an earlier version of the patch without the quotes that I didn't
see?

Or is the shell on the test robot doing something really really odd,
and it's somehow nds32-specific?

Linus

Hi Linus,

It can be reproduced with '-a' option in dash:

    $ a="!"
    $ [ "$a" = ".size" ]
    $ [ "$a" = ".size" -a "$b" = ".LPBX0," ]
    sh: 2: [: =: unexpected operator

and there is a advice for the option at https://wiki.ubuntu.com/DashAsBinSh, I'm not sure it's the best practice or not.

    While dash supports most uses of the -a and -o options, they have very confusing semantics even in bash and are best avoided. Commands like the following:
        [ \( "$foo" = "$bar" -a -f /bin/baz \) -o ! -x /bin/quux ]
    should be replaced with:
        (([ "$foo" = "$bar" ] && [ -f /bin/baz ]) || [ ! -x /bin/quux ])

Best Regards,
Rong Chen