NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/57016: libedit no longer supports multi-line history



>Number:         57016
>Category:       lib
>Synopsis:       libedit no longer supports multi-line history
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 20 23:00:01 +0000 2022
>Originator:     Ricky Zhou
>Release:        N/A
>Organization:
>Environment:
N/A
>Description:
Some applications take multi-line commands, so they may call readline() multiple times and then call add_history() on a multi-line command.

Handling of multiline history was broken in https://github.com/NetBSD/src/commit/a90574952794b3edab8563128abe32af6ba66a4c#diff-1d1f44076d0edc654db369bcf936482e9d7938c541dad2a84cee3eea2f9f7608L468-L470

Specifically, the code:

lastidx = count - 1;
if (buf[lastidx] == '\n')
    buf[lastidx] = '\0';

was replaced with:

buf[strcspn(buf, "\n")] = '\0';

The new code cuts the string at the first newline rather than trimming off the last newline.

Thanks to Ethan Wei for identifying this issue!
>How-To-Repeat:
Call add_history/history on a multi-line string, then call readline/el_gets. Press up, enter. After pressing up, the multi-line command is displayed, but after pressing enter, only the first line is returned.
>Fix:
Could the problematic piece of the patch be reverted? Not sure if the behavior change was intentional.



Home | Main Index | Thread Index | Old Index