From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22924 invoked by alias); 16 Jun 2010 23:56:05 -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: 28044 Received: (qmail 2500 invoked from network); 16 Jun 2010 23:55:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) MIME-Version: 1.0 In-Reply-To: <20100609165429.7e19ca2c@csr.com> References: <15865.1276088859@csr.com> <20100609165429.7e19ca2c@csr.com> Date: Wed, 16 Jun 2010 15:06:53 -0700 Message-ID: Subject: Re: PATCH: bug in ${(z)...} with newlines From: Bart Schaefer To: Zsh hackers list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 wrote: > On Wed, 9 Jun 2010 07:34:47 -0700 > Bart Schaefer wrote: >> On Wed, Jun 9, 2010 at 6:07 AM, Peter Stephenson wrote: >> > This must be a bug, mustn't it? >> > >> > % foo=3D$'one\ntwo' >> > % print ${(z)foo} >> > one ; two >> >> Yes, but (z) is really for parsing, not merely splitting. > > Hmm. =A0I'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 manua= l > 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 w= ith: +> 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.