I made a bash script to use sendmail to send emails. However, when it asks for input, whenever I try to use the arrow keys to correct a typo, instead of moving the cursor, it just adds ^[[D
to the end. How can I fix that?
You can simply press Shift-right-arrow, and then start typing. In contrast, to these combination shift-arrow commands which move the cursor to the beginning and end of lines, the Ctrl-left-arrow and Ctrl-right-arrow keys move the screen image 20 spaces in the opposite direction to the arrow, without moving the cursor.
Use the -e
option to read
. From the bash manual:
-e
Readline (see Command Line Editing) is used to obtain the line. Readline uses the current (or default, if line editing was not previously active) editing settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With