diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 9557fc03..27523f5b 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -193,7 +193,7 @@ parse_options() { _parse_config_files "/etc/percona-toolkit/percona-toolkit.conf" "/etc/percona-toolkit/$TOOL.conf" "$HOME/.percona-toolkit.conf" "$HOME/.$TOOL.conf" fi - _parse_command_line "$@" + _parse_command_line "${@:-""}" } _parse_pod() { @@ -285,7 +285,7 @@ _eval_po() { _parse_config_files() { - for config_file in "$@"; do + for config_file in "${@:-""}"; do test -f "$config_file" || continue while read config_opt; do @@ -319,7 +319,7 @@ _parse_command_line() { local required_arg="" local spec="" - for opt in "$@"; do + for opt in "${@:-""}"; do if [ "$opt" = "--" -o "$opt" = "----" ]; then HAVE_EXT_ARGV=1 continue @@ -2308,14 +2308,13 @@ main() { # Execute the program if it was not included from another file. # This makes it possible to include without executing, and thus test. -set +u if [ "${0##*/}" = "$TOOL" ] \ || [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then -set -u + # Set up temporary dir. mk_tmpdir # Parse command line options. - parse_options "$0" "$@" + parse_options "$0" "${@:-""}" # Verify that --sleep, if present, is positive if [ -n "$OPT_SLEEP" ] && [ "$OPT_SLEEP" -lt 0 ]; then @@ -2336,7 +2335,7 @@ set -u # a connection then. [ "$OPT_READ_SAMPLES" ] || check_mysql - main "$@" + main "${@:-""}" fi # ############################################################################ diff --git a/bin/pt-summary b/bin/pt-summary index 37dbdccd..f60f8387 100755 --- a/bin/pt-summary +++ b/bin/pt-summary @@ -200,7 +200,7 @@ parse_options() { _parse_config_files "/etc/percona-toolkit/percona-toolkit.conf" "/etc/percona-toolkit/$TOOL.conf" "$HOME/.percona-toolkit.conf" "$HOME/.$TOOL.conf" fi - _parse_command_line "$@" + _parse_command_line "${@:-""}" } _parse_pod() { @@ -292,7 +292,7 @@ _eval_po() { _parse_config_files() { - for config_file in "$@"; do + for config_file in "${@:-""}"; do test -f "$config_file" || continue while read config_opt; do @@ -326,7 +326,7 @@ _parse_command_line() { local required_arg="" local spec="" - for opt in "$@"; do + for opt in "${@:-""}"; do if [ "$opt" = "--" -o "$opt" = "----" ]; then HAVE_EXT_ARGV=1 continue @@ -2180,14 +2180,13 @@ sigtrap() { local PTFUNCNAME=sigtrap; # Execute the program if it was not included from another file. This makes it # possible to include without executing, and thus test. -set +u if [ "${0##*/}" = "$TOOL" ] \ || [ "${0##*/}" = "bash" -a "$_" = "$0" ]; then -set -u + # Set up temporary dir. mk_tmpdir # Parse command line options. - parse_options "$0" "$@" + parse_options "$0" "${@:-""}" usage_or_errors "$0" po_status=$? rm_tmpdir @@ -2196,7 +2195,7 @@ set -u exit $po_status fi - main "$@" + main "${@:-""}" fi diff --git a/lib/bash/parse_options.sh b/lib/bash/parse_options.sh index 5ae56fc7..40cc144d 100644 --- a/lib/bash/parse_options.sh +++ b/lib/bash/parse_options.sh @@ -213,7 +213,7 @@ parse_options() { fi # Finally, parse the command line. - _parse_command_line "$@" + _parse_command_line "${@:-""}" } _parse_pod() { @@ -318,7 +318,7 @@ _eval_po() { _parse_config_files() { - for config_file in "$@"; do + for config_file in "${@:-""}"; do # Next config file if this one doesn't exist. test -f "$config_file" || continue @@ -377,7 +377,7 @@ _parse_command_line() { local required_arg="" local spec="" - for opt in "$@"; do + for opt in "${@:-""}"; do if [ "$opt" = "--" -o "$opt" = "----" ]; then HAVE_EXT_ARGV=1 continue