Skip to content

Instantly share code, notes, and snippets.

@xirixiz
Forked from hyamamoto/Makefile.ask_passwd
Created November 24, 2021 12:34
Show Gist options
  • Save xirixiz/31e9ce13e5ccc82bc7c9906c2120817d to your computer and use it in GitHub Desktop.
Save xirixiz/31e9ce13e5ccc82bc7c9906c2120817d 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