From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11122 invoked by alias); 29 May 2015 15:44: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: 35327 Received: (qmail 13378 invoked from network); 29 May 2015 15:43:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Message-ID: <5568893A.2070701@inlv.org> Date: Fri, 29 May 2015 17:43:54 +0200 From: Martijn Dekker User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-workers@zsh.org Subject: Re: Arith parsing bug with minus after $# References: <55676FB1.9080401@inlv.org> <20150529160237.6f329071@pwslap01u.europe.root.pri> In-Reply-To: <20150529160237.6f329071@pwslap01u.europe.root.pri> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Peter Stephenson schreef op 29-05-15 om 17:02: > On Thu, 28 May 2015 21:42:41 +0200 > Martijn Dekker wrote: >> % set -- >> % echo $# >> 0 >> % echo $(($#-1)) >> 41 > > That's not a compatibility issue, that's just plain weird. I don't know > the POSIX terminology. > > The problem is the overloading of "#" --- the test to establish what to > do with it is trying too hard to resolve to ${#-}, which is a valid > substitution, because it hasn't taken into account that there are no > braces. So what you're seeing is ${#-}1. Ah, yes... ${#-} is the length in characters of $-, the shell options that are set. Before 'emulate sh', the length of $- is 8, and after, it's 4. That explains the results I got. The fix is working; thanks yet again. - M.