I know that user input can be read silently using bash with read -s someVar
and I was wondering if there is a /bin/sh
equivalent that allows user input without displaying it on the command line?
Note: I am just curious if /bin/sh
read
supports this feature somehow.
Use the stty
command to turn off echoing of typed characters.
get_entry () {
printf "Choose: "
stty -echo
IFS= read -r choice
stty echo
printf '\n'
}
get_entry
printf "You chose %s\n" "$choice"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With