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

Re: ${a[(i)pattern]} if a=()



On Mar 18, 12:13pm, Peter Stephenson wrote:
}
} I've read through the manual again, and you're right, the sense of it is
} it should be one, because it's "off the end".  As Stephane pointed out,
} zero looks screwy here (whatever the arguments about validity of
} indices).  So you should commit the patch.

Done.

Looking at documenation for this, I was reminded about this recent bit:

     Note that in subscripts with both `r' and `R' pattern characters
     are active even if they were substituted for a parameter
     (regardless of the setting of GLOB_SUBST which controls this
     feature in normal pattern matching).  It is therefore necessary to
     quote pattern characters for an exact string match.

Maybe we could press the (e) flag into service here?  I haven't looked
at how hard that would be to do, but it's semantically similar to the
existing use:

e
     This flag has no effect and for ordinary arrays is retained for
     backward compatibility only.  For associative arrays, this flag
     can be used to force * or @ to be interpreted as a single key
     rather than as a reference to all values.  This flag may be used
     on the left side of an assignment.



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