On Monday 24 September 2007, Duncan wrote: > Donnie Berkholz posted: > > For tests, pick a style > > [[ ]] or [ ] and stick with it. The [[ ]] one is pretty nice because it > > generally doesn't require quotes, so the code looks a lot cleaner. > > Can you point me (and anyone else that may be interested) to a nice > explanation of the difference? i use `man bash` myself ... > I've always wondered why [[ ]] is > considered "better" than [ ] for tests. as Donnie pointed out, it handles quoting sanely ... it also allows for extended bash logic tests (like matching and regexps) as well as your standard logic operators fails: f="moo cow with space" [ ${f} = blah ] works: [[ ${f} == blah ]] wildcards: [[ ${f} == *moo* ]] C logic operators (rather than crappy shell '-a' / '-o' / etc...): [[ moo == foo || moo == moo && blah == doit ]] -mike