Last active
July 25, 2022 16:16
-
-
Save rsperl/c9eeef0dc88d8598173494aa02d3436c to your computer and use it in GitHub Desktop.
do not echo stdin to stdout #shell #snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# show prompt without a newline | |
echo -n "Password:" | |
# Turn off echo | |
stty -echo | |
# Read what the user typed | |
read passwd | |
# Turn echo back on | |
stty echo | |
# instead of turning echo off and back on, you can also | |
# save the current tty settings with | |
# stty_orig=$(stty -g) | |
# turn echo off, then restore the tty settings with | |
# stty $stty_orig | |
echo "you entered: $passwd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment