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

Re: Parameter expansion



Roland Jesse wrote:
> But why do I do get the following than?
> 
> % if [ ! ${+BLURB} ]; then
> then> echo "BLURB not set"
> then> else
> else> echo "BLURB set"
> else> fi
> BLURB set
> % 

That's becuase

% if [ ! 0 ]; then print no; else print yes; fi
yes
% if [ ! 1 ]; then print no; else print yes; fi
yes

It's testing whether the string has length zero, which it doesn't.  You
need arithmetical evaluation; change the [ to (( and the ] to )) and
everything should work.

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author