Description
Issue #1459 caused me to notice that this block of code is, at best, confusing:
Lines 454 to 464 in 1fd82bd
The problem is that it is assigning to shell var .sh.subscript
a value having absolutely nothing to do with the documented meaning of that var. The code could have used literally any arbitrary, otherwise ostensibly private, var to temporarily hold the value returned by tput cuu1
. Abusing .sh.subscript
is gross and unnecessary. It's also dangerous since, theoretically, it could have been set prior to that block of code being run. Which, again, illustrates that the old AST team relied far too much on knowledge of the existing implementation rather than first principals when writing such code.
We should modify ksh to not use the tput
command in this fashion. Ksh should be using the curses API to get this info rather than running an external command. Note that there are only two places in the code that use an external tput
command in this fashion. The other being in emacs_escape()
to run tput clear
when [ctrl-L] is seen. Which means that if a tput
command wasn't found when the build was configured you can't use [ctrl-L] to clear the screen. Which seems suboptimal and needlessly expensive. Not to mention that even if tput
was found when the build was configured there is no guarantee it will be in $PATH
when it is needed. Which explains the 2>/dev/null
redirection in the ed_setup()
function. But not why the same redirection isn't present in the emacs_escape()
function.