Bash read backspace button behavior problem

前端 未结 2 961
情深已故
情深已故 2021-01-05 08:10

When using read in bash, pressing backspace does not delete the last character entered, but appears to append a backspace to the input buffer. Is there any way I can change

2条回答
  •  没有蜡笔的小新
    2021-01-05 08:57

    The option -n nchars turns the terminal into raw mode, so your best chance is to rely on readline (-e) [docs]:

    $ read -n10 -e VAR
    

    BTW, nice idea, although I would leave the end of the word to the user (it's a knee-jerk reaction to press return).

提交回复
热议问题