>>>>> On Sun, 12 Jun 2016, Benda Xu wrote: >> Inside [[ ]] quotes are generally not needed. (There are several other >> instances of this.)
> I thought so too, but with an experiment:
> bash --version
> GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
> bash -l
> $ [[ -f a b ]] && echo hi
> bash: syntax error in conditional expression
> bash: syntax error near `b'
> $ [[ -f "a b" ]] && echo hi
> hi
Wrong experiment, so you get wrong results. :)
$ foo="a b"
$ [[ -f ${foo} ]] && echo yes || echo no
no
$ touch "a b"
$ [[ -f ${foo} ]] && echo yes || echo no
yes
> So it seems that [[ ]] does need quotes.
I doesn't around a variable.
Ulrich
pgpMwPyoPQ0RX.pgp
Description: PGP signature
