diff --git a/bin/pt-align b/bin/pt-align index 0f7bbd9a..09fa0c0a 100755 --- a/bin/pt-align +++ b/bin/pt-align @@ -480,6 +480,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-archiver b/bin/pt-archiver index 40c6baf5..67796f2c 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -1209,6 +1209,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 70361cf4..9476c5b9 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -1207,6 +1207,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-deadlock-logger b/bin/pt-deadlock-logger index b94b3a88..cd27515d 100755 --- a/bin/pt-deadlock-logger +++ b/bin/pt-deadlock-logger @@ -557,6 +557,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-diskstats b/bin/pt-diskstats index bb55ecd3..19644c29 100755 --- a/bin/pt-diskstats +++ b/bin/pt-diskstats @@ -553,6 +553,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 918e65df..bafe5322 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -1544,6 +1544,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-fifo-split b/bin/pt-fifo-split index b82cc91a..8fc7ce6b 100755 --- a/bin/pt-fifo-split +++ b/bin/pt-fifo-split @@ -481,6 +481,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-find b/bin/pt-find index c29e4c61..42437add 100755 --- a/bin/pt-find +++ b/bin/pt-find @@ -973,6 +973,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-fingerprint b/bin/pt-fingerprint index 832c506c..f1740241 100755 --- a/bin/pt-fingerprint +++ b/bin/pt-fingerprint @@ -482,6 +482,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-fk-error-logger b/bin/pt-fk-error-logger index fe63941e..f6e5c09d 100755 --- a/bin/pt-fk-error-logger +++ b/bin/pt-fk-error-logger @@ -552,6 +552,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index dfeb66a1..2c06ae84 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -1304,6 +1304,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 70ea0305..92ec144a 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -1134,6 +1134,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-kill b/bin/pt-kill index d0b591d9..e47cc0e5 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -562,6 +562,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 4ec5feec..873b4471 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -570,6 +570,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-query-digest b/bin/pt-query-digest index b104aaa8..ba5ee016 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -1802,6 +1802,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-show-grants b/bin/pt-show-grants index a412b68c..16864d36 100755 --- a/bin/pt-show-grants +++ b/bin/pt-show-grants @@ -483,6 +483,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-slave-delay b/bin/pt-slave-delay index 0c2b1ba1..9b20b377 100755 --- a/bin/pt-slave-delay +++ b/bin/pt-slave-delay @@ -555,6 +555,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-slave-find b/bin/pt-slave-find index 502099bd..c0ccdfa7 100755 --- a/bin/pt-slave-find +++ b/bin/pt-slave-find @@ -490,6 +490,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index 1810266a..8e18f61b 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -707,6 +707,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index f2e877e4..9183e55d 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -2231,6 +2231,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 8d861365..f5e12dd1 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -570,6 +570,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-table-usage b/bin/pt-table-usage index 966bee20..c990c581 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -1575,6 +1575,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-upgrade b/bin/pt-upgrade index ed548cf2..fbb3a2a6 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -1799,6 +1799,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-variable-advisor b/bin/pt-variable-advisor index 09092e88..35b2463c 100755 --- a/bin/pt-variable-advisor +++ b/bin/pt-variable-advisor @@ -559,6 +559,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/bin/pt-visual-explain b/bin/pt-visual-explain index 034d3c1d..dfd775d9 100755 --- a/bin/pt-visual-explain +++ b/bin/pt-visual-explain @@ -1156,6 +1156,12 @@ sub get_opts { $self->{errors} = []; + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + $ARGV[0] =~ s/^'(.*)'$/$1/ + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/lib/DSNParser.pm b/lib/DSNParser.pm index 9ec39bd3..4e6ad905 100644 --- a/lib/DSNParser.pm +++ b/lib/DSNParser.pm @@ -147,7 +147,7 @@ sub parse { foreach my $key ( keys %$opts ) { PTDEBUG && _d('Finding value for', $key); $final_props{$key} = $given_props{$key}; - if ( !defined $final_props{$key} + if ( !defined $final_props{$key} && defined $prev->{$key} && $opts->{$key}->{copy} ) { $final_props{$key} = $prev->{$key}; diff --git a/lib/OptionParser.pm b/lib/OptionParser.pm index 92f64dfe..b1c2c699 100644 --- a/lib/OptionParser.pm +++ b/lib/OptionParser.pm @@ -615,6 +615,13 @@ sub get_opts { $self->{errors} = []; # --config is special-case; parse them manually and remove them from @ARGV + if ( @ARGV && $ARGV[0] =~/^--config=/ ) { + $ARGV[0] = substr($ARGV[0],9); + # Clean '" independently because we need to match start/end with the same char ' or " + $ARGV[0] =~ s/^'(.*)'$/$1/; + $ARGV[0] =~ s/^"(.*)"$/$1/; + $self->_set_option('config', shift @ARGV); + } if ( @ARGV && $ARGV[0] eq "--config" ) { shift @ARGV; $self->_set_option('config', shift @ARGV); diff --git a/t/lib/OptionParser.t b/t/lib/OptionParser.t index 3522dc49..7e0ff9fe 100644 --- a/t/lib/OptionParser.t +++ b/t/lib/OptionParser.t @@ -1595,6 +1595,10 @@ ok( 'Parses special --config option first', ); +@ARGV = ("--config=$trunk/t/lib/samples/empty",'--cat'); +$o->get_opts(); +ok($o->got('config'), 'Got --config='); + $o = new OptionParser( description => 'OptionParser.t parses command line options.', usage => "$PROGRAM_NAME "