Fixed a bug where the #include fakery caused chained scripts that wanted to call cmdarg were unable to do so and were unable to see CMDARG_ associative arrays, so wierd things started happening

This commit is contained in:
2013-10-29 19:10:08 -04:00
parent 51b3114748
commit 5facea1cc5

View File

@@ -322,41 +322,34 @@ function cmdarg_purge
arrays="cmdarg_cfg CMDARG CMDARG_REV CMDARG_OPTIONAL CMDARG_REQUIRED" arrays="cmdarg_cfg CMDARG CMDARG_REV CMDARG_OPTIONAL CMDARG_REQUIRED"
arrays="$arrays CMDARG_DESC CMDARG_DEFAULT CMDARG_VALIDATORS CMDARG_INFO" arrays="$arrays CMDARG_DESC CMDARG_DEFAULT CMDARG_VALIDATORS CMDARG_INFO"
arrays="$arrays CMDARG_FLAGS CMDARG_TYPES" arrays="$arrays CMDARG_FLAGS CMDARG_TYPES"
for arr in $arrays unset $arr
do unset $arr[*]
str='${!'"$arr"'[@]}'
for key in $(eval "echo $str")
do
str="$arr[$key]"
eval "unset $str"
done
done
CMDARG_GETOPTLIST="h" CMDARG_GETOPTLIST="h"
} }
if [[ "${_DEFINED_CMDARG}" == "" ]]; then # Holds the final map of configuration options
export _DEFINED_CMDARG=0 declare -A cmdarg_cfg
# Holds the final map of configuration options # Maps (short arg) -> (long arg)
declare -A cmdarg_cfg declare -A CMDARG
# Maps (short arg) -> (long arg) # Maps (long arg) -> (short arg)
declare -A CMDARG declare -A CMDARG_REV
# Maps (long arg) -> (short arg) # A list of optional arguments (e.g., no :)
declare -A CMDARG_REV declare -a CMDARG_OPTIONAL
# A list of optional arguments (e.g., no :) # A list of required arguments (e.g., :)
declare -a CMDARG_OPTIONAL declare -a CMDARG_REQUIRED
# A list of required arguments (e.g., :) # Maps (short arg) -> (description)
declare -a CMDARG_REQUIRED declare -A CMDARG_DESC
# Maps (short arg) -> (description) # Maps (short arg) -> default
declare -A CMDARG_DESC declare -A CMDARG_DEFAULT
# Maps (short arg) -> default # Maps (short arg) -> validator
declare -A CMDARG_DEFAULT declare -A CMDARG_VALIDATORS
# Maps (short arg) -> validator # Miscellanious info about this script
declare -A CMDARG_VALIDATORS declare -A CMDARG_INFO
# Miscellanious info about this script # Map of (short arg) -> flags
declare -A CMDARG_INFO declare -A CMDARG_FLAGS
# Map of (short arg) -> flags # Map of (short arg) -> type (string, array, hash)
declare -A CMDARG_FLAGS declare -A CMDARG_TYPES
# Map of (short arg) -> type (string, array, hash)
declare -A CMDARG_TYPES if [[ "${CMDARG_GETOPTLIST}" == "" ]]; then
CMDARG_GETOPTLIST="h" CMDARG_GETOPTLIST="h"
fi fi