No Prompt & Password Fill Install for Homebrew
The -s
option is working for me, so I don't know why it doesn't work for you.
Have you tried to add #!/bin/sh
(or #!/bin/bash
) in the top of your script ??
If you use the -n
option on echo
you'll get the input on the same line as the label.
So the below is having the input: Password: <waiting for input>
, and on the next line it just print the password entered - the awk
is just for testing that the pipe was working. And then I've added a loop so that something always need to be entered.
#!/bin/sh
readPassword
echo $PASSWORD | awk '{print $1}'
readPassword() {
echo -n "Password: "
read -s PASSWORD
echo ""
if [[ -z "$PASSWORD" ]]; then
printf '%s\n' "A password is required..."
readPassword
fi
}