Use ${@:-""} rather than $@, prevents error on ksh when no opts given. Remove set +u to see if it is no longer needed.

This commit is contained in:
Daniel Nichter
2012-08-14 11:07:10 -06:00
parent 4a44794d07
commit 9ddf90eeca
3 changed files with 15 additions and 17 deletions

View File

@@ -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
# ############################################################################

View File

@@ -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

View File

@@ -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