Fixed the exporting of cmdarg_ and CMDARG_ variables for subshells (for real this time)
This commit is contained in:
56
cmdarg.sh
56
cmdarg.sh
@@ -324,35 +324,39 @@ function cmdarg_purge
|
|||||||
arrays="$arrays CMDARG_FLAGS CMDARG_TYPES"
|
arrays="$arrays CMDARG_FLAGS CMDARG_TYPES"
|
||||||
for arr in $arrays
|
for arr in $arrays
|
||||||
do
|
do
|
||||||
unset $arr
|
str='${!'"$arr"'[@]}'
|
||||||
unset $arr[*]
|
for key in $(eval "echo $str")
|
||||||
|
do
|
||||||
|
str="$arr[$key]"
|
||||||
|
eval "unset $str"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
CMDARG_GETOPTLIST="h"
|
CMDARG_GETOPTLIST="h"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Holds the final map of configuration options
|
if [[ "${_DEFINED_CMDARG}" == "" ]]; then
|
||||||
declare -A cmdarg_cfg
|
export _DEFINED_CMDARG=0
|
||||||
# Maps (short arg) -> (long arg)
|
# Holds the final map of configuration options
|
||||||
declare -A CMDARG
|
declare -A cmdarg_cfg
|
||||||
# Maps (long arg) -> (short arg)
|
# Maps (short arg) -> (long arg)
|
||||||
declare -A CMDARG_REV
|
declare -A CMDARG
|
||||||
# A list of optional arguments (e.g., no :)
|
# Maps (long arg) -> (short arg)
|
||||||
declare -a CMDARG_OPTIONAL
|
declare -A CMDARG_REV
|
||||||
# A list of required arguments (e.g., :)
|
# A list of optional arguments (e.g., no :)
|
||||||
declare -a CMDARG_REQUIRED
|
declare -a CMDARG_OPTIONAL
|
||||||
# Maps (short arg) -> (description)
|
# A list of required arguments (e.g., :)
|
||||||
declare -A CMDARG_DESC
|
declare -a CMDARG_REQUIRED
|
||||||
# Maps (short arg) -> default
|
# Maps (short arg) -> (description)
|
||||||
declare -A CMDARG_DEFAULT
|
declare -A CMDARG_DESC
|
||||||
# Maps (short arg) -> validator
|
# Maps (short arg) -> default
|
||||||
declare -A CMDARG_VALIDATORS
|
declare -A CMDARG_DEFAULT
|
||||||
# Miscellanious info about this script
|
# Maps (short arg) -> validator
|
||||||
declare -A CMDARG_INFO
|
declare -A CMDARG_VALIDATORS
|
||||||
# Map of (short arg) -> flags
|
# Miscellanious info about this script
|
||||||
declare -A CMDARG_FLAGS
|
declare -A CMDARG_INFO
|
||||||
# Map of (short arg) -> type (string, array, hash)
|
# Map of (short arg) -> flags
|
||||||
declare -A CMDARG_TYPES
|
declare -A CMDARG_FLAGS
|
||||||
|
# Map of (short arg) -> type (string, array, hash)
|
||||||
if [[ "${CMDARG_GETOPTLIST}" == "" ]]; then
|
declare -A CMDARG_TYPES
|
||||||
CMDARG_GETOPTLIST="h"
|
CMDARG_GETOPTLIST="h"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user