Skip to content

Instantly share code, notes, and snippets.

@hyamamoto
Created August 1, 2018 00:03
Show Gist options
  • Save hyamamoto/72f81a4ee18a127daf0f3b65f0e71423 to your computer and use it in GitHub Desktop.
Save hyamamoto/72f81a4ee18a127daf0f3b65f0e71423 to your computer and use it in GitHub Desktop.
asking a password in a makefile.
ask_password:
@$(eval PASSWORD=$(shell stty -echo; read -p "Password: " pwd; stty echo; echo $$pwd))
echo $(PASSWORD)
ask_password_twice:
while true; do \
read -s -p "Password: " password; \
echo; \
read -s -p "Password (again): " password2; \
echo; \
[ "$$password" = "$$password2" ] && break || echo "Please try again"; \
done && echo $$password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment