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

From: Herbert Xu
Date: Tue Mar 16 2021 - 05:52:21 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> See:
>
> [torvalds@ryzen ~]$ a="!" [ "$a" = ".size" ]
>
> is fine, but
>
> [torvalds@ryzen ~]$ a="!" [ $a = ".size" ]
> -bash: [: =: unary operator expected

This isn't doing what you think it's doing. The first assignment
to a is not in effect when the shell is expanding $a so what you're
actually running is

a="!" [ = .size ]

Which is why it bombs out.

To get the desired result you need a semicolon:

$ a="!"; [ $a = ".size" ]
$

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt