hstr
hstr copied to clipboard
[hstr 3.0] pressing Esc on system w/o TIOCSTI outputs page full of garbage
I just installed hstr 3.0 on my Arch Linux system w/o TIOCSTI and replaced the hstr config in my .bashrc
with the output of hstr --show-configuration
. Then I opened a new console.
When I invoke hstr with Ctrl+R and then abort it by pressing Esc, instead of getting my shell prompt back immediately, it waits for another key press and then outputs a page full of garbage. It looks to have grabbed some lines from my .bash_history
and shortened long lines by putting … at the end, and line endings are replaced with a ^M^[[<nr>d
sequence where <nr>
is a number starting from 1 and counting up for each next line.
Example of what happens after pressing Esc, to abort hstr;
I think there's a problem with this function from hstr --show-configuration
output:
function hstrnotiocsti {
{ HSTR_OUT="$( { </dev/tty hstr ${READLINE_LINE}; } 2>&1 1>&3 3>&- )"; } 3>&1;
READLINE_LINE="$(hstr ${READLINE_LINE})"
READLINE_POINT=${#READLINE_LINE}
}
If I replace that with the previous code, from hstrcygwin function in https://github.com/dvorka/hstr/pull/481#issue-1630468851, then hstr works as expected and pressing Esc cleanly aborts it:
function hstrnotiocsti {
offset=${READLINE_POINT}
READLINE_POINT=0
{ READLINE_LINE=$(</dev/tty hstr ${READLINE_LINE:0:offset} 2>&1 1>&$hstrout); } {hstrout}>&1
READLINE_POINT=${#READLINE_LINE}
}