Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ -n $v ]] versus (( $#v > 0 ))
- X-seq: zsh-users 12242
- From: Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
- To: Nikolai Weibull <now@xxxxxxxx>
- Subject: Re: [[ -n $v ]] versus (( $#v > 0 ))
- Date: Tue, 20 Nov 2007 11:15:59 -0600
- Cc: ZSH Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <dbfc82860711200445g19cd0177s1755ddfcfb246990@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <dbfc82860711200445g19cd0177s1755ddfcfb246990@xxxxxxxxxxxxxx>
In the last episode (Nov 20), Nikolai Weibull said:
> What does the (imaginary) Zsh Scripting Style Guide say about
>
> if [[ -n $v ]]; then
> ...
> fi
>
> versus
>
> if (( $#v > 0 )); then
> ...
> fi
>
> Is it simply legacy that causes people to write [[ -n $v ]] over ((
> $#v > 0 ))?
You forgot [[ $#v -eq 0 ]] :)
I like using (( $+v )) myself, since I usually want to know whether a
variable is set (even to "") or not.
--
Dan Nelson
dnelson@xxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author