Bash script Arrow Keys produces weird characters

后端 未结 2 1999
抹茶落季
抹茶落季 2021-01-03 05:00

Consider the following minimised Bash Script:

echo Enter your name:
read NAME
echo $NAME

Now if I run the script and enter a name and want

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 05:50

    Thanks to Andreas and some due dilligence with a search engine, I was able to rewrite my script:

    echo Enter your name:
    read -e NAME
    echo $NAME
    

    Now navigating through the input with arrow keys, works like a expected.

    Here you can learn more about the read builtin command.

提交回复
热议问题