Skip to content

Instantly share code, notes, and snippets.

@hotwatermorning
Created January 4, 2018 10:04
Show Gist options
  • Select an option

  • Save hotwatermorning/20418525c570132a05d9367b045b5e1d to your computer and use it in GitHub Desktop.

Select an option

Save hotwatermorning/20418525c570132a05d9367b045b5e1d to your computer and use it in GitHub Desktop.
input_password.sh
# $1 : description (ex, MYSQL DB Name)
input_password() {
tmp1=""
while [ "$tmp1" = "" ]; do
read -sp "Enter $1: " tmp1
tty -s && echo >&2
if [ -z tmp1 ]; then
continue
fi
read -sp "Confirm $1: " tmp2
tty -s && echo >&2
if [ "$tmp1" = "$tmp2" ]; then
echo $tmp1
return 0
fi
done
}
echo `input_password "MYSQL Root Pass"`
echo `input_password "MYSQL Root Pass2"`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment