From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 324 invoked by alias); 14 May 2011 04:37:01 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 29277 Received: (qmail 27035 invoked from network); 14 May 2011 04:36:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110513213633.ZM13611@torch.brasslantern.com> Date: Fri, 13 May 2011 21:36:33 -0700 In-reply-to: Comments: In reply to Mikael Magnusson "Infinite recursions in math evaluation" (May 13, 11:37pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh workers Subject: Re: Infinite recursions in math evaluation MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On May 13, 11:37pm, Mikael Magnusson wrote: } } [...] Aha, actually a=a; $(( a )) crashes in the same way. (On } a machine with a presumably less optimized/buggy compile, it does } print "zsh: math recursion limit exceeded" instead of crashing). Is it } simply a user error? I wouldn't expect either of these expressions to } recursively look up values of the parameter until it encountered a } number, but this is indeed what happens: } % a=b; b=c; c=d; d=e; e=f; f=5; echo $(( a )) } 5 } bash does the same... } } I scanned quickly through the "Arithmetic Evaluation" section and } found nothing suggesting that this should happen. It's implicit in this: Named parameters and subscripted arrays can be referenced by name within an arithmetic expression without using the parameter expansion syntax. For example, ((val2 = val1 * 2)) assigns twice the value of $val1 to the parameter named val2. "The value of $val1" in an arithmetic context is the result of doing arithmetic evaluation on whatever is stored in the parameter. If that's the name of another (or even the same) parameter, then ...