I am writing a bash script in which I read single characters from input. I am using read -n 1 -s
. -n 1
- read only one character; -s
is a silent mode in which typed characters will not be visible.
The problem is that when the command currently being executed is not read
(whenever any other commands are executed in the bash script), the character is displayed in the terminal.
This is the normal behavior of the program in the terminal. To disable this, echo mode is usually disabled, for example, using the termios library.
How can I achieve this in a bash script?
I prefer solutions in pure bash / Unix commands (without other scripting languages ββlike python, perl, etc.).
source share