Pressing Ctrl-C while waiting for input from the read -sp operation returns the operation back to the command line, but the data entry is hidden, as if read -s still running.
Example
#!/bin/sh sig_handler() { echo "SIGINT received" exit 1 } trap "sig_handler" SIGINT read -sp "ENTER PASSWORD: " password echo echo $password
which is usually done as follows:
$~ ./example.sh ENTER PASSWORD: password $~ text -bash: text: command not found
but if you press Ctrl-C on ENTER PASSWORD, you will get
$~ ./example.sh ENTER PASSWORD: SIGINT received $~ -bash: text: command not found
where text or any other next command is not displayed as input until you update with reset .
How can you return the text to normal input after receiving a SIGINT? read -p "ENTER PASSWORD: " password not required for obvious security reasons.
source share