Date: Wed, 9 Jul 1997 01:05:33 +0200 (MET DST) From: Wolfgang Helbig <helbig@MX.BA-Stuttgart.De> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/4064: libedit's history search is broken Message-ID: <199707082305.BAA14379@helbig.informatik.ba-stuttgart.de> Resent-Message-ID: <199707082310.QAA15126@hub.freebsd.org>
index | next in thread | raw e-mail
>Number: 4064
>Category: bin
>Synopsis: libedit's history search is broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Jul 8 16:10:01 PDT 1997
>Last-Modified:
>Originator: Wolfgang Helbig
>Organization:
>Release: FreeBSD 3.0-CURRENT i386
>Environment:
>Description:
The error shows up e. g. in sh(1), which uses the libedit.
Do a ``set -o vi'' to enable vi style line editing.
If you search for `ls' in the history, the shell will either
show all commands that contain a `l', or will beep at you,
even if there are commands that contain `ls' in the past.
>How-To-Repeat:
Enter the following commands to get a history.
# sh
# set -o vi
# lll
# llll
Now hit the escape key to enter the vi commands, enter
/llll, to search for the last occurence of the string `llll'
in the history. Depending on whatever, the shell will show
you the command `llll', which is correct, or beep at you,
which is wrong. Hit the `N'-key to repeat the search, the
shell might show you `lll', which is wrong, it should beep
at you instead.
>Fix:
Index: search.c
===================================================================
RCS file: /usr/cvsroot/src/lib/libedit/search.c,v
retrieving revision 1.5
diff -c -r1.5 search.c
*** search.c 1997/06/25 08:14:17 1.5
--- search.c 1997/07/08 21:39:09
***************
*** 464,471 ****
(void)strncpy(tmpbuf, el->el_search.patbuf, sizeof(tmpbuf) - 1);
el->el_search.patbuf[0] = '.';
el->el_search.patbuf[1] = '*';
! (void)strncpy(&el->el_search.patbuf[2], tmpbuf,
! sizeof(el->el_search.patbuf) - 3);
el->el_search.patlen++;
el->el_search.patbuf[el->el_search.patlen++] = '.';
el->el_search.patbuf[el->el_search.patlen++] = '*';
--- 464,470 ----
(void)strncpy(tmpbuf, el->el_search.patbuf, sizeof(tmpbuf) - 1);
el->el_search.patbuf[0] = '.';
el->el_search.patbuf[1] = '*';
! (void)strncpy(&el->el_search.patbuf[2], tmpbuf, EL_BUFSIZ - 3);
el->el_search.patlen++;
el->el_search.patbuf[el->el_search.patlen++] = '.';
el->el_search.patbuf[el->el_search.patlen++] = '*';
***************
*** 479,486 ****
tmpbuf[tmplen++] = '*';
#endif
tmpbuf[tmplen] = '\0';
! (void)strncpy(el->el_search.patbuf, tmpbuf,
! sizeof(el->el_search.patbuf) - 1);
el->el_search.patlen = tmplen;
}
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
--- 478,484 ----
tmpbuf[tmplen++] = '*';
#endif
tmpbuf[tmplen] = '\0';
! (void)strncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1);
el->el_search.patlen = tmplen;
}
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199707082305.BAA14379>
