Re: [PATCHv2] completion: make compatible with zsh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2010/8/30 SZEDER Gábor <szeder@xxxxxxxxxx>
> On Thu, Aug 26, 2010 at 10:45:56PM -0400, Mark Lodato wrote:
> > @@ -2417,3 +2433,29 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
> >  complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
> >       || complete -o default -o nospace -F _git git.exe
> >  fi
> > +
> > +if [[ -z $ZSH_VERSION ]]; then
>
> -z?  I think you wanted to use -n here, like at the other places.

Oh, yes, sorry.  This was a mistake.  Thanks for catching it.


> Nit: why "if [[ ... ]]"?  FWIW "if [ ... ]" would be enough.

Because you don't need to quote variables with [[ ... ]] --- e.g. [
$lines = 0 ] fails, though in this case this feature does not matter
--- and because [[ ... ]] is faster.

Bash 4.1.5:
> time (for (( i = 0; i < 200000; i++ )); do [ -z $foo ]; done)
real    0m3.430s
user    0m3.240s
sys     0m0.180s
> time (for (( i = 0; i < 200000; i++ )); do [[ -z $foo ]]; done)
real    0m2.219s
user    0m2.090s
sys     0m0.100s

Zsh 4.3.10:
> time (for (( i = 0; i < 2000000; i++ )); do [ -z $foo ]; done)
(; for ((i = 0; i < 2000000; i++ )) do; [ -z $foo ]; done; )  13.56s
user 1.64s system 99% cpu 15.327 total
> time (for (( i = 0; i < 2000000; i++ )); do [[ -z $foo ]]; done)
(; for ((i = 0; i < 2000000; i++ )) do; [[ -z $foo ]]; done; )  4.62s
user 0.01s system 99% cpu 4.644 total

Is there a reason to prefer [ ... ] ?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]