From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id SAA16047 for ; Wed, 29 May 1996 18:31:31 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA00049; Wed, 29 May 1996 04:19:38 -0400 (EDT) Resent-Date: Wed, 29 May 1996 04:19:38 -0400 (EDT) Message-Id: <199605290819.KAA06804@hydra.ifh.de> To: zsh-workers@math.gatech.edu Subject: Re: History !# substitutions In-reply-to: "schaefer@candle.brasslantern.com"'s message of "Tue, 28 May 1996 22:33:03 MET." <960528223307.ZM2584@candle.brasslantern.com> Date: Wed, 29 May 1996 10:19:06 +0200 From: Peter Stephenson Resent-Message-ID: <"m1S7w1.0.e.PY0hn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1218 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > The !# substitution, which shuffles words from the current command line, > has always been a bit flaky in zsh, but now it seems to be broken entirely. > > zagzig% echo foo bar !#:1 > zsh: no words available from current command Profuse apologies: this no doubt came in why I upgraded the word-selection part of the history mechanism and didn't know enough about !# to make it work. The following seems to do the trick; do let me know of unforeseen behaviour. (I've deleted that particular error message since `no such word in event' seems to describe the remaining occasions when there is an error entirely adequately.) I hope flakiness can now be avoided entirely. *** Src/hist.c.curhist Fri May 10 22:22:30 1996 --- Src/hist.c Wed May 29 10:12:15 1996 *************** *** 1111,1131 **** getargs(Histent elist, int arg1, int arg2) { char *ret; ! int pos1; ! if (arg1 >= elist->nwords || arg2 >= elist->nwords) { /* remember, argN is indexed from 0, nwords is total no. of words */ inerrflush(); ! if (!elist->nwords) ! zerr("no words available from current command", NULL, 0); ! else ! zerr("no such word in event", NULL, 0); return NULL; } ! pos1 = elist->words[2*arg1]; ret = dupstring(elist->text + pos1); ! ret[elist->words[2*arg2+1] - pos1] = '\0'; return ret; } --- 1111,1137 ---- getargs(Histent elist, int arg1, int arg2) { char *ret; ! short *words; ! int pos1, nwords; ! if (elist == curhistent) { ! words = chwords; ! nwords = chwordpos/2; ! } else { ! words = elist->words; ! nwords = elist->nwords; ! } ! ! if (arg1 >= nwords || arg2 >= nwords) { /* remember, argN is indexed from 0, nwords is total no. of words */ inerrflush(); ! zerr("no such word in event", NULL, 0); return NULL; } ! pos1 = words[2*arg1]; ret = dupstring(elist->text + pos1); ! ret[words[2*arg2+1] - pos1] = '\0'; return ret; } -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330 Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.