From cbf16194caefdf55b83a8544c719eb68f3490dd1 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 2 Oct 2009 14:09:01 +0300 Subject: [PATCH] When using --help --verbose give error and abort if there are any unknown options mysql-test/r/mysqld_option_err.result: Test that mysqld --not-known-option --help --verbose gives error mysql-test/t/mysqld_option_err.test: Test that mysqld --not-known-option --help --verbose gives error --- mysql-test/r/mysqld_option_err.result | 2 ++ mysql-test/t/mysqld_option_err.test | 9 +++++++++ sql/mysqld.cc | 9 ++++----- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/mysqld_option_err.result b/mysql-test/r/mysqld_option_err.result index 255f109b788..4afcc5e0cb1 100644 --- a/mysql-test/r/mysqld_option_err.result +++ b/mysql-test/r/mysqld_option_err.result @@ -3,4 +3,6 @@ Test bad binlog format. Test bad default storage engine. Test non-numeric value passed to number option. Test that bad value for plugin enum option is rejected correctly. +Test that --help --verbose works +Test that --not-known-option --help --verbose gives error Done. diff --git a/mysql-test/t/mysqld_option_err.test b/mysql-test/t/mysqld_option_err.test index 4ff1bcd8cbd..6e4183a6f8c 100644 --- a/mysql-test/t/mysqld_option_err.test +++ b/mysql-test/t/mysqld_option_err.test @@ -46,5 +46,14 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err; --error 7 --exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables $EXAMPLE_PLUGIN_OPT --plugin-load=EXAMPLE=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +# +# Test that an wrong option with --help --verbose gives an error +# + +--echo Test that --help --verbose works +--exec $MYSQLD --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 +--echo Test that --not-known-option --help --verbose gives error +--error 2 +--exec $MYSQLD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1 --echo Done. diff --git a/sql/mysqld.cc b/sql/mysqld.cc index dc3cf8d158a..f4c6ae4d56a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4020,9 +4020,6 @@ server."); plugins_are_initialized= TRUE; /* Don't separate from init function */ } - if (opt_help) - unireg_abort(0); - /* we do want to exit if there are any other unknown options */ if (defaults_argc > 1) { @@ -4047,13 +4044,15 @@ server."); if (defaults_argc) { - fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n" - "Use --verbose --help to get a list of available options\n", + fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n", my_progname, *tmp_argv); unireg_abort(1); } } + if (opt_help) + unireg_abort(0); + /* if the errmsg.sys is not loaded, terminate to maintain behaviour */ if (!errmesg[0][0]) unireg_abort(1);