LDP/LDP/guide/docbook/abs-guide/erase.sh

19 lines
647 B
Bash
Raw Permalink Normal View History

2001-09-04 13:36:09 +00:00
#!/bin/bash
# erase.sh: Using "stty" to set an erase character when reading input.
echo -n "What is your name? "
2003-08-25 14:48:48 +00:00
read name # Try to backspace
#+ to erase characters of input.
2003-11-03 16:25:16 +00:00
# Problems?
2001-09-04 13:36:09 +00:00
echo "Your name is $name."
2003-08-25 14:48:48 +00:00
stty erase '#' # Set "hashmark" (#) as erase character.
2001-09-04 13:36:09 +00:00
echo -n "What is your name? "
2003-08-25 14:48:48 +00:00
read name # Use # to erase last character typed.
2001-09-04 13:36:09 +00:00
echo "Your name is $name."
exit 0
2006-06-22 14:28:13 +00:00
# Even after the script exits, the new key value remains set.
# Exercise: How would you reset the erase character to the default value?