Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Parameter expansion
- X-seq: zsh-users 2337
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: Parameter expansion
- Date: Mon, 17 May 1999 11:23:22 +0200
- In-reply-to: "Roland Jesse"'s message of "Mon, 17 May 1999 11:39:18 DFT." <14143.58310.693584.42423@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
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