pt-mysql-summary added ask-pass option

This commit is contained in:
frank-cizmich
2015-05-18 14:25:25 -03:00
parent 66c74af47b
commit 074c1edec5
2 changed files with 23 additions and 2 deletions
+14 -1
View File
@@ -75,6 +75,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV
OPT_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files
usage() {
@@ -175,6 +176,7 @@ parse_options() {
OPT_ERRS=0
OPT_VERSION=""
OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then
@@ -489,7 +491,14 @@ mysql_options() {
if [ -n "$OPT_USER" ]; then
MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER"
fi
if [ -n "$OPT_PASSWORD" ]; then
if [ -n "$OPT_ASK_PASS" ]; then
stty -echo
>&2 printf "Enter MySQL password: "
read GIVEN_PASS
stty echo
printf "\n"
MYSQL_ARGS="$MYSQL_ARGS --password=$GIVEN_PASS"
elif [ -n "$OPT_PASSWORD" ]; then
MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD"
fi
@@ -2923,6 +2932,10 @@ All options after -- are passed to C<mysql>.
mysqldump and summarize all databases. See L<"--databases">.
=item --ask-pass
Prompt for a password when connecting to MySQL.
=item --config
type: string
+9 -1
View File
@@ -40,7 +40,15 @@ mysql_options() {
if [ -n "$OPT_USER" ]; then
MYSQL_ARGS="$MYSQL_ARGS --user=$OPT_USER"
fi
if [ -n "$OPT_PASSWORD" ]; then
# handle ask-pass option (issue lp#1455486)
if [ -n "$OPT_ASK_PASS" ]; then
stty -echo
>&2 printf "Enter MySQL password: "
read GIVEN_PASS
stty echo
printf "\n"
MYSQL_ARGS="$MYSQL_ARGS --password=$GIVEN_PASS"
elif [ -n "$OPT_PASSWORD" ]; then
MYSQL_ARGS="$MYSQL_ARGS --password=$OPT_PASSWORD"
fi