From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10485 invoked from network); 13 Sep 1999 16:36:19 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Sep 1999 16:36:19 -0000 Received: (qmail 5702 invoked by alias); 13 Sep 1999 16:35:59 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2599 Received: (qmail 5693 invoked from network); 13 Sep 1999 16:35:58 -0000 Date: Mon, 13 Sep 1999 12:35:28 -0400 From: Sweth Chandramouli To: zsh-users@sunsite.auc.dk Subject: Re: evaluating a condition Message-ID: <19990913123528.A14510@cj952583-b.alex1.va.home.com> Mail-Followup-To: zsh-users@sunsite.auc.dk References: <990912235140.ZM23741@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.95i In-Reply-To: <990912235140.ZM23741@candle.brasslantern.com> Sender: sweth@cj952583-b.alex1.va.home.com On Sun, Sep 12, 1999 at 11:51:39PM +0000, Bart Schaefer wrote: > On Sep 12, 8:41pm, Gaspar Bakos wrote: > } Subject: evaluating a condition > } > } I have the following script, and I would like to print the numbers in the > } terminal from ${min} to ${max}, if both of them are smaller than 10. > > At first I thought you'd found a bug in the math parser, but: > > } export min=$3;export max=$4; > } if (($[min]<10 && $[max]<10)) then > ^^ > There's a metafied space here. I think zsh is interpreting "\240$[max]" as > an identifier; e.g. if max=11, the identifier name is "\240\061\061". That > identifier isn't defined, so it's value is 0 which is always < 10. ??? what? ((...)), at least according to the docs (and as implemented in ksh) is just another syntax for `let '...''. all the "metafying" (actually, quoting is unmetafying) does is prevent the shell from interpreting the space as a word separator; once the string to be evaluated is passed to let, the space is a space again, and let _should_ (and does, in 3.1.6) simply ignore it, such that the entire block of code does work. > } for i in {${min}..${max}}; do echo $i; done > } fi > > This is a danger of permitting identifiers to contain non-ascii characters. ??? okay, what did you do to bart? :) i assume you meant non-printable and not non-ascii here, though technically a space is still printable. one related question that i've long wondered but never about cared enough to ask: is there a difference between the $[...] and ${...} notations? -- sweth. -- Sweth Chandramouli ; Will Work For Food. *