Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Arith parsing bug with minus after $#



Bart Schaefer schreef op 29-05-15 om 20:09:
> On May 29, 2015 8:02 AM, "Peter Stephenson" <p.stephenson@xxxxxxxxxxx>
> 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

- M.



Messages sorted by: Reverse Date, Date, Thread, Author