Linus Torvalds <torva...@linux-foundation.org> 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 <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Reply via email to