From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5561 invoked by alias); 17 Aug 2011 06:26:38 -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: 29694 Received: (qmail 26262 invoked from network); 17 Aug 2011 06:26:26 -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 closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110816232616.ZM17198@torch.brasslantern.com> Date: Tue, 16 Aug 2011 23:26:16 -0700 In-reply-to: <110816203630.ZM7065@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: 'patch -Rp0 <110816203630.ZM7065@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: 'patch -Rp0 -1) { } 1359 /* We want to reuse the current word position */ } 1360 chwordpos = hwgetword; } 1361 /* Start from where previous word ended, if possible */ } 1362 hptr = chline + chwords[chwordpos ? chwordpos - 1 : 0]; } 1363 } } } This makes me suspect that hwgetword was not incremented at some place } where it should have been, but I don't know where -- or whether that is } really the problem. I just put a debug statement in there and ran "make check" and that particular code branch is never excercised. Immediately before that, there's this: 1350 /* end of word reached and we've already begun a word */ 1351 if (hptr > chline + chwords[chwordpos-1]) { 1352 chwords[chwordpos++] = hptr - chline; Everything is fine at this point. We've got chwords[4] pointing at "<" and chwords[5] (which represents the end of that word) pointing at "f". We should be ready to start the next word. So why do we want to do the stuff at line 1360 & 1361? What is the point of "reuse the current word position"? I suspect the answer is up in ihwbegin(): 1331 /* If we're expanding an alias, we should overwrite the expansion 1332 * in the history. 1333 */ 1334 if ((inbufflags & INP_ALIAS) && !(inbufflags & INP_HIST)) 1335 hwgetword = chwordpos; 1336 else 1337 hwgetword = -1; And sure enough: torch% alias -g foo=bar torch% echo foo ../../zsh-4.0/Src/hist.c:1359: Re-using current word position bar And: torch% : -Rp0 -1) { + if (hwgetword > -1 && + (inbufflags & INP_ALIAS) && !(inbufflags & INP_HIST)) { /* We want to reuse the current word position */ chwordpos = hwgetword; /* Start from where previous word ended, if possible */ It's possible that we also want to assign hwgetword = -1 at this point, but I think that would be wrong in a recursively-expanding alias.