aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkate.ward <kate.ward@forestent.com>2009-04-01 13:31:18 +0000
committerkate.ward <kate.ward@forestent.com>2009-04-01 13:31:18 +0000
commit9ccba51f4fa3d2b694bcf50fa6f13c31c2d47e56 (patch)
treee179193f19bcfbeca9f195b646b7acfff63c894e
parent87b0c2e5bc4aab241c8cfba76a043bae9d642ca3 (diff)
downloadshflags-9ccba51f4fa3d2b694bcf50fa6f13c31c2d47e56.tar.gz
replaced global __flags_argc var with passing local var around
-rw-r--r--source/1.0/src/shflags11
1 files changed, 7 insertions, 4 deletions
diff --git a/source/1.0/src/shflags b/source/1.0/src/shflags
index cf56e94..eff46f6 100644
--- a/source/1.0/src/shflags
+++ b/source/1.0/src/shflags
@@ -179,7 +179,6 @@ __flags_boolNames=' ' # space separated list of boolean flag names
__flags_longNames=' ' # space separated list of long flag names
__flags_shortNames=' ' # space separated list of short flag names
-__flags_argc=0 # count of non-flag arguments
__flags_columns='' # screen width in columns
__flags_opts='' # temporary storage for parsed getopt flags
@@ -612,11 +611,15 @@ _flags_getoptEnhanced()
# dynamic to support any number of flags.
#
# Args:
+# argc: int: original command-line argument count
# @: varies: output from getopt parsing
# Returns:
# integer: a FLAGS success condition
_flags_parseGetopt()
{
+ _flags_argc_=$1
+ shift
+
flags_return=${FLAGS_TRUE}
if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then
@@ -631,7 +634,7 @@ _flags_parseGetopt()
# properly give user access to non-flag arguments mixed in between flag
# arguments. Its usage was replaced by FLAGS_ARGV, and it is being kept only
# for backwards compatibility reasons.
- FLAGS_ARGC=`expr $# - 1 - ${__flags_argc}`
+ FLAGS_ARGC=`expr $# - 1 - ${_flags_argc_}`
# handle options. note options with values must do an additional shift
while true; do
@@ -793,7 +796,7 @@ FLAGS()
DEFINE_boolean 'help' false 'show this help' 'h'
# record original number of args for use elsewhere
- __flags_argc=$#
+ flags_argc_=$#
# parse options
if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then
@@ -804,7 +807,7 @@ FLAGS()
flags_return=$?
if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then
- _flags_parseGetopt "${__flags_opts}"
+ _flags_parseGetopt ${flags_argc_} "${__flags_opts}"
flags_return=$?
fi