Is it possible to output text to a shell window, via bash script, that is user-editable? I essentially want to pre-fill certain information and give the user the ability to edit it if it's wrong.
For instance, if I were to write in a script:
echo -n "Enter your name: Anthony"
while read user_input
do
# do stuff with $user_input
done
How can I allow the user to inline edit the word Anthony
only (aka, don't allow backspacing past the A
in Anthony
), and how can I store the value into a variable once the RETURN key is pressed?
EDIT
I'm looking for something similar to the -i
option of read
(see answer posted here), but this is only available on bash 4+. Is there an alternative for bash 3?