From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3394 invoked by alias); 29 May 2015 20:54:29 -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: 35332 Received: (qmail 5611 invoked from network); 29 May 2015 20:54:23 -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=-0.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,FSL_HELO_BARE_IP_2 autolearn=no autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1432932501; bh=MYti+4YpqJT2r/ZyptIGiwGeLV9HmJAN5UdTL9M2JdY=; h=From:To:In-Reply-To:References:Subject:Date; b=MteVC1WRzaDPF6MHmtqME+VXR+rfkJw8Hh2QQytGrcwp97rmG65yjwd6rKSN9rKzZ UUnXBlT+UORbQ64/hZJGtHoUZRtr5xMYozAw6B/QrBrVfddTNlxnoeKKXnZ2liPOIJ haXlL5YHOaYyik6Pj0dMRLBMYXz9pod9IljAPRHo= From: ZyX To: Martijn Dekker , "zsh-workers@zsh.org" In-Reply-To: <5568BF27.80806@inlv.org> References: <55676FB1.9080401@inlv.org> <20150529160237.6f329071@pwslap01u.europe.root.pri> <5568BF27.80806@inlv.org> Subject: Re: Arith parsing bug with minus after $# MIME-Version: 1.0 Message-Id: <5423831432932500@web1o.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 29 May 2015 23:48:20 +0300 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 29.05.2015, 22:34, "Martijn Dekker" : > Bart Schaefer schreef op 29-05-15 om 20:09: >>  On May 29, 2015 8:02 AM, "Peter Stephenson" >>  wrote: >>>  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. >>  I think this actually was discussed on austin-group a few months back.  My >>  recollection is that zsh's behavior was deemed permissible and I therefore >>  thought no more about it at the time. > > It is incompatible with every other shell and with the POSIX spec. > Parameter expansion is only supposed to be done if braces are present. See: > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 It says that they are optional: > The parameter name or symbol can be enclosed in braces, which are optional except for positional parameters with more than one digit or when parameter is a name and is followed by a character that could be interpreted as part of the name. The matching closing brace shall be determined by counting brace levels, skipping over enclosed quoted strings, and command substitutions. This is the fourth paragraph. But later it explicitly says that not enclosed in single braces may only be names or single-character variables. I.e. $#- is ${#}-, $10 is ${1}0, … Besides $#- zsh has things like $array[index]: needs not be enclosed in braces (depends on some option: in `emulate sh` or `emulate ksh` this is ${array}[index], same in ksh). Or $file:h. I guess there are more I do not know about. > > - M.