NetBSD-Bugs archive

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

lib/57376: libedit tab completion escapes spaces



>Number:         57376
>Category:       lib
>Synopsis:       libedit tab completion escapes spaces
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 24 11:35:00 +0000 2023
>Originator:     Jorge
>Release:        9.3
>Organization:
none
>Environment:
Not needed.
>Description:
I use the readline interface of libedit for a little program. It's a BASIC interpreter, I implemented readline and libedit support (through its readline interface) to allow line editing. My notes show that this was on 2018-02-14 . I tested the program working in NetBSD, FreeBSD, OpenBSD and Slackware Linux. Autocompletion was working fine. Then, I can't say when, a change was made in libedit and autocompletion did not work as intended anymore.

The problem is:

I install a rl_completion_entry_function. When libedit calls that function when the user presses TAB to autocoplete the editing line, I return a string for the completion, but somehow libedit is not respecting the string I pass, but escapes spaces and quotes (I think it is supposing that it is a filename, but it shoulnd't).

Note that this is happening in other systems now: FreeBSD, and Linuxes with  https://www.thrysoee.dk/editline/ . Also note that I am using only the readline interface that libedit provides. If I link against GNU readline, the behaviour is correct.

The code of my program is at:

https://github.com/jorgicor/bas55

The file using readline completion:

https://github.com/jorgicor/bas55/blob/master/src/getlin.c

I think that this behavior is happening for some years now. I'm a bit surprised that no one has reported it. Maybe the readline interface is not used that much, I don't know.
>How-To-Repeat:
I can't think of another way to test it, than to use my program. It's a little C program.

wget https://jorgicor.niobe.org/bas55/bas55-1.19.tar.gz
tar -xvzf bas55-1.19.tar.gz
cd bas55-1.19
./configure --with-libedit
make
src/bas55

The program starts and lets you write a BASIC program. Write 2 lines:

10 print "hello"
20 end

Write "list", you should see:

10 PRINT "HELLO"
20 END

Now, autocompletion for a line works this way: if you enter the number of a line and press TAB, you will get the line back. Test it with the line 10. Write 10 and press TAB. This happens:

10TAB
10\ PRINT \"HELLO\"

That is, my rl_completion entry_function is returning the string '10 PRINT "HELLO"' but libedit is escaping it. The correct will be to print_

10 PRINT "HELLO"

Note that some years have passed, but as far as I remeber this was working ok in 2018 (but maybe I am wrong, my notes say that I tested on NetBSD 7.1.1).

Also, more important, if I linnk against GNU readline instead of libedit (can't be done with this version as it is, some files need to be modified, but I can prepare something if needed) this works as intended, that is nothing is escaped.

I can provide a version that links with GNU readline if needed.
>Fix:



Home | Main Index | Thread Index | Old Index