diff --git a/bin/pt-ioprofile b/bin/pt-ioprofile index 5077e2e6..c1743c24 100755 --- a/bin/pt-ioprofile +++ b/bin/pt-ioprofile @@ -359,6 +359,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 6cfcc0f5..50ce239c 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -361,6 +361,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 1ee490ca..52f9686e 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -361,6 +361,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 cb7a6395..db2a4663 100755 --- a/bin/pt-summary +++ b/bin/pt-summary @@ -368,6 +368,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 76140704..13df9c43 100644 --- a/lib/bash/parse_options.sh +++ b/lib/bash/parse_options.sh @@ -427,6 +427,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 # ############################################################################ diff --git a/t/lib/samples/bash/po005.sh b/t/lib/samples/bash/po005.sh new file mode 100644 index 00000000..38b2cc99 --- /dev/null +++ b/t/lib/samples/bash/po005.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +: + +# ############################################################################ +# Documentation +# ############################################################################ +:<<'DOCUMENTATION' +=pod + +=head1 NAME + +pt-stalk - Wait for a condition to occur then begin collecting data. + +=head1 OPTIONS + +=over + +=item --notify-by-email + +type: string + +something about mailing. + +=item --help + +Print help. + +=back + +=head1 ENVIRONMENT + +No env vars used. + +=cut + +DOCUMENTATION