I'm trying to write a script that requests the user password for some sudo
-related commands. My goal is to emulate the default method that OS X uses to obtain the user's password, Password:
followed by a key-like symbol, as seen in the screenshot attached below:
I tried the answer from How to get a password from a shell script without echoing over on Stack Overflow that uses read -s
, but that results in Password:
without the key symbol when run from a script, but displays the symbol when run from the Terminal itself . What is this key symbol, and can I find it under the Characters menu?
read -s
in Terminal, so I assume this is actually a feature of bash. Maybe a look into the source code (opensource.apple.com/source/bash/bash-99/bash-3.2/builtins/…) might give more clues.read -s
set up correctly in my script. Thanks for your help!