[arch-general] [PATCH 04/48] Use [[ ]] instead of [ ] for conditional checking when running in bash.

Victor Lowther victor.lowther at gmail.com
Wed Jun 30 18:31:45 EDT 2010


On Thu, 2010-07-01 at 00:24 +0200, bardo wrote:
> 2010/7/1 Daenyth Blank <daenyth+arch at gmail.com>:
> > On Wed, Jun 30, 2010 at 17:56, Thomas Bächler <thomas at archlinux.org> wrote:
> >> Am 30.06.2010 23:47, schrieb Victor Lowther:
> >>> It is worth 10 - 30% speedup whenever you want to compare something.
> >>
> >> Where do you get this from? I always used [ ], and I found it
> >> sufficient. Why is [[ ]] faster?
> >>
> >>> -if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then
> >>> +if [[ $USECOLOR = YES || $USECOLOR = yes ]]; then
> >>
> >> Why do you get rid of the quoting here? Quoting is nice.
> >>
> >>
> >
> > Quoting is not needed in [[ and it makes the code uglier.
> >
> 
> Ditto. May I also suggest a link[1] to those that do not know all the
> beauties of double square brackets? By the way, the whole BashFAQ in
> there is really interesting, it has lots of advanced tips 'n tricks.
> 
> Corrado
> 
> 
> [1] http://mywiki.wooledge.org/BashFAQ/031

greycat and friends are awesome, it is true.  I learned alot reading
gregs wiki and hanging out on #bash.

-- 
Victor Lowther
LPIC2 UCP RHCE 


More information about the arch-general mailing list