From c2b006eeaf546ff47713f519756ab3eb192810f2 Mon Sep 17 00:00:00 2001 From: "Brian Fraser fraserb@gmail.com" <> Date: Mon, 20 Aug 2012 19:22:31 -0300 Subject: [PATCH] Fix for 1038995: pt-stalk notify-by-email fails --- bin/pt-ioprofile | 3 +++ bin/pt-mysql-summary | 3 +++ bin/pt-stalk | 3 +++ bin/pt-summary | 3 +++ lib/bash/parse_options.sh | 3 +++ t/lib/bash/parse_options.sh | 14 +++++++++++++- 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/pt-ioprofile b/bin/pt-ioprofile index 28463753..c33dcab6 100755 --- a/bin/pt-ioprofile +++ b/bin/pt-ioprofile @@ -356,6 +356,9 @@ _parse_command_line() { if [ -f "$PT_TMPDIR/po/$base_opt" ]; then opt_is_negated=1 opt="$base_opt" + else + opt_is_negated="" + opt=$(echo $opt | sed 's/^-*//') fi else if $(echo $opt | grep '^--no-' >/dev/null); then diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 3759e31a..eb9ad2df 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -358,6 +358,9 @@ _parse_command_line() { if [ -f "$PT_TMPDIR/po/$base_opt" ]; then opt_is_negated=1 opt="$base_opt" + else + opt_is_negated="" + opt=$(echo $opt | sed 's/^-*//') fi else if $(echo $opt | grep '^--no-' >/dev/null); then diff --git a/bin/pt-stalk b/bin/pt-stalk index f92f8263..8e8a0ada 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -358,6 +358,9 @@ _parse_command_line() { if [ -f "$PT_TMPDIR/po/$base_opt" ]; then opt_is_negated=1 opt="$base_opt" + else + opt_is_negated="" + opt=$(echo $opt | sed 's/^-*//') fi else if $(echo $opt | grep '^--no-' >/dev/null); then diff --git a/bin/pt-summary b/bin/pt-summary index 68662a0c..8bd71eaf 100755 --- a/bin/pt-summary +++ b/bin/pt-summary @@ -365,6 +365,9 @@ _parse_command_line() { if [ -f "$PT_TMPDIR/po/$base_opt" ]; then opt_is_negated=1 opt="$base_opt" + else + opt_is_negated="" + opt=$(echo $opt | sed 's/^-*//') fi else if $(echo $opt | grep '^--no-' >/dev/null); then diff --git a/lib/bash/parse_options.sh b/lib/bash/parse_options.sh index 5ae56fc7..37949e06 100644 --- a/lib/bash/parse_options.sh +++ b/lib/bash/parse_options.sh @@ -424,6 +424,9 @@ _parse_command_line() { if [ -f "$PT_TMPDIR/po/$base_opt" ]; then opt_is_negated=1 opt="$base_opt" + else + opt_is_negated="" + opt=$(echo $opt | sed 's/^-*//') fi else # Handle normal cases: --option and --no-option. diff --git a/t/lib/bash/parse_options.sh b/t/lib/bash/parse_options.sh index a1d59842..ca6326c8 100644 --- a/t/lib/bash/parse_options.sh +++ b/t/lib/bash/parse_options.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -plan 81 +plan 83 TMPFILE="$TEST_PT_TMPDIR/parse-opts-output" TOOL="pt-stalk" @@ -246,6 +246,18 @@ is "$OPT_DISK_BYTES_FREE" "104857600" "Size: 100M" parse_options "$T_LIB_DIR/samples/bash/po004.sh" is "$OPT_DISK_BYTES_FREE" "104857600" "Size: 100M default" +# ############################################################################ +# Bug 1038995: pt-stalk notify-by-email fails +# https://bugs.launchpad.net/percona-toolkit/+bug/1038995 +# ############################################################################ + +# This failed because --notify was misparsed as --no-tify +parse_options "$T_LIB_DIR/samples/bash/po005.sh" +is "$OPT_NOTIFY_BY_EMAIL" "" "Bug 1038995: --notify-by-email is empty by default" + +parse_options "$T_LIB_DIR/samples/bash/po005.sh" --notify-by-email foo@bar.com +is "$OPT_NOTIFY_BY_EMAIL" "foo@bar.com" "Bug 1038995: ...but gets set without errors if specified" + # ############################################################################ # Done # ############################################################################