Here’s a cut down version. With the call to el_wrap('test', user_input, user_output, user_error)
commented out it works fine. With it uncommented the first 2 lines are read and echoed OK, but the third line is echoed but not read in, and when return is pressed the process spins off to oblivion, consuming 100% CPU. Platform is Debian 12.11.
#!/opt/swipl/bin/swipl
:- initialization(main, main).
main(_) :-
prompt(P, '>> '),
prompt1('Enter Line1: '),
read_line_to_string(user_input, Line1),
format('Line 1 is "~w"~n', [Line1]),
prompt1('Enter Line2: '),
read_line_to_string(user_input, Line2),
format('Line 2 is "~w"~n', [Line2]),
writeln('Initialising libeditline'),
el_wrap('test', user_input, user_output, user_error),
el_history(user_input, setsize(100)),
el_history(user_input, setunique(true)),
(exists_file('history') -> el_read_history(user_input, 'history') ; true),
prompt1('Enter Line3: '),
read_line_to_string(user_input, Line3),
format('Line 3 is "~w"~n', [Line3]),
el_add_history(user_input, Line3),
prompt1('Enter Line4: '),
read_line_to_string(user_input, Line4),
format('Line 4 is "~w"~n', [Line4]),
el_add_history(user_input, Line4),
prompt(_, P),
el_write_history(user_input, 'history')
.