I just saw this code somewhere.
It allows the user to enter his password and change it to an asterisk/star.
But it doesn't recognize the backspace key.
The code thinks that the backspace is part of the password.
What should I do to make it recognize the backspace?
And can someone explain this code to me?
Especially the IFS, the options of read, and the $'\0'
Here is the code.
\#!/bin/bash unset password prompt="Enter Password:" while IFS= read -p "$prompt" -r -s -n 1 char do if [[ $char == $'\0' ]] then break fi prompt='*' password+="$char" done echo echo "Done. Password=$password"