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

Zsh bug/patch



While working with a terminal which didn't support zle as well as it
should have I came across an inconsistency in the behaviour of the
history substitution operator.

In particular, a substitution of the form !?string[?] when coupled with
the % operator to retrieve the word which matched the ?string? search.
(According to the man page)

Behaviour I noticed, and can track back as far as 2.6-beta13 was that
the word _following_ the word matched would be retrieved. I had a copy
of 2.6-beta10 sitting on an old machine which did not exhibit the bug.

I checked with a copy of 3.1.1-beta which I downloaded this evening from
the Australian mirror site. The bug was still in evidence. It would seem
to be a simple off-by-one bug. I include both a trace of the problem,
and a proposed patch below.

I would appreciate a response so that I can make sure this patch was
received and know whether it solves the problem of a useful feature being
unworkable.

Bruce Murphy.

Script started on Fri Apr  4 21:57:13 1997

# Old behaviour. Present in zsh-2.6-beta13 up to zsh-3.1.1-beta
neotoma /usr/src/shells/zsh-3.1.1/Src >echo rat1rat snoopy
rat1rat snoopy
neotoma /usr/src/shells/zsh-3.1.1/Src >echo !?1?:%
echo snoopy
snoopy

# New 'correct' behaviour. Last known to be present in 
# zsh-2.6-beta10
neotoma /usr/src/shells/zsh-3.1.1/Src >./zsh
neotoma /usr/src/shells/zsh-3.1.1/Src >echo rat1rat snoopy
rat1rat snoopy
neotoma /usr/src/shells/zsh-3.1.1/Src >echo !?1?:%
echo rat1rat
rat1rat

Script done on Fri Apr  4 21:58:24 1997


*** zsh-3.1.1-orig/Src/hist.c	Wed Jan  8 21:08:44 1997
--- zsh-3.1.1/Src/hist.c	Fri Apr  4 21:54:22 1997
***************
*** 940,946 ****
  	    int pos = s - he->text;
  	    while (t1 < he->nwords && he->words[2*t1] <= pos)
  		t1++;
! 	    *marg = t1;
  	    return t0;
  	}
      return -1;
--- 940,946 ----
  	    int pos = s - he->text;
  	    while (t1 < he->nwords && he->words[2*t1] <= pos)
  		t1++;
! 	    *marg = t1 - 1;
  	    return t0;
  	}
      return -1;


-- 
Packrat (BSc/BE;COSO;Wombat II Designer)
Nihil illegitemi carborvndvm.



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