I have the following piece of code that will allow me to type any letter or number:
#!/bin/bash
while IFS= read -s -n1 char; do
if ! [[ $char =~ [A-Za-z0-9]+$ ]]; then break; fi
value+=$char
echo -n "*"
done
echo
echo "val = $value"
What I would like to do, however, is allow for the backspace, delete and arrow keys to perform like normal without causing the script to abort. I'm assuming I need to capture some form of ANSI equivalent and just have a different operation if that key is used. But I'm not sure how to do that...