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

Re: PATCH: bug in ${(z)...} with newlines



Sorry to have left this sit so long, I had relatives in town for my
son's high school graduation and wasn't really keeping up with all my
email.

On Wed, Jun 9, 2010 at 8:54 AM, Peter Stephenson
<Peter.Stephenson@xxxxxxx> wrote:
> On Wed, 9 Jun 2010 07:34:47 -0700
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>> On Wed, Jun 9, 2010 at 6:07 AM, Peter Stephenson <pws@xxxxxxx> wrote:
>> > This must be a bug, mustn't it?
>> >
>> > % foo=$'one\ntwo'
>> > % print ${(z)foo}
>> > one ; two
>>
>> Yes, but (z) is really for parsing, not merely splitting.
>
> Hmm.  I've only ever used (z) for splitting words (which is why it was 'z',
> since 's' was used), which is my memory of why it was introduced.  Now
> you're telling me it's for something other than what it says in the manual
> which just says parsing is to find the words, and I can't use it without
> jumping through hoops.  Nor can I think of a case where I would use it to
> find lines of code.

I did a dive into the list archive and the addition of (z) originated
with this remark by Felix Rosencrantz (zsh-workers/10951):

-> I wasn't sure how to break up the values of $history to find the start
-> of commands, and to break up along word boundaries.  I was thinking
-> that we might need C code support for that.

Sven proposed something unworkable involving $historywords, and I replied with:

+> I think having a way to chop a string into shell words -- something like
+> what you did for copy-prev-shell-word -- would be more effective.

This eventually resulted in Sven posting the patch for (z).

Now, this was all in the context of the _history completer which may
very well by now be doing its thing in an entirely different way -- I
don't find any use of (z) in _history or indeed anywhere in
Completion/**/*(.) [scanning with egrep] that conflicts with your
proposed change.  I just want to make sure the ramifications have been
considered.

> I can certainly believe the completion system, which uses the same code
> underneath, might be relying on undocumented 'intentional' features.

I find calls to bufferwords() in Zle/{zle_hist,zle_misc}.c and subst.c
but not in completion (oddly, as a comment indicates that's where it
originally came from).  The only place your change may have a
detectable effect is in the implementation of copyprevshellword() in
zle_misc.



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