2

i'm trying to practice to do a nice and neat interface. However, i'm stuck at this problem. I'm trying to underline the input of the user which i managed to do it using this method

echo -n "Title : "; read -p "$(tput smul)" getTitle; tput rmul 

tput smul is used to underline the word while tput rmul is used to remove the underline after this statement is successful.

Unfortunately, when i accidentally typed wrongly and decided to back space, the underline did not disappear accordingly.

Instead, the underline remains there even though i removed all the user input.

Is there any solution for this?

Bryan
  • 8,488
  • 14
  • 52
  • 78

1 Answers1

2

Use readline via the -e flag:

echo -n "Title : "; read -ep "$(tput smul)" getTitle; tput rmul
hek2mgl
  • 152,036
  • 28
  • 249
  • 266