Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [[ -n $v ]] versus (( $#v > 0 ))



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