PR/51518: Jay West: prompt is interleaved with client output
Both these issues are caused by rl_restore_handler not DTRT; fix
it so that it kills the internal libedit state completely. This is
inefficient, but it works.
Also fix:
1. add append_history()/H_NSAVE_FP
2. call the rl_startup_hook before printing the first prompt as documented.
callint it from rl_initialize breaks python, because the callback ends
up being invoked before the readline module is installed, and we end up
dereferencing a NULL pointer.
3. add el_resize_terminal.
With those changes, s/lreadline/ledit/g in python works.
Let "el.h" include everything needed for struct editline,
and don't include that stuff multiple times. That also improves
consistency, also avoids circular inclusions, and also makes it
easier to follow what is going on, even though not quite as nice.
But it seems like the best we can do...
The posix 'sh' specification defines vi-mode editing quite tightly.
The netbsd libedit code (used by sh to do this) was missing several
features, there were also minor errors in others.
Compare netbsd sh to the definition available from:
http://www.opengroup.org/onlinepubs/007904975/utilities/sh.html
In particular the following were not supported:
U - undo all changes to line
| - goto column
Y - yank to end of line
y - yank
# - comment out current line
@ - take input from shell alias [1]
G - goto numbered line in history buffer
v - edit history line with vi
_ - append word from last input line
. - redo last command
Other minor changes have also been made.
[1] This needs the shell to define an appropriate routine to
return the text of the alias. There is no requirement that
such a function exist.