From: Matthias Kruk Date: Thu, 11 Aug 2022 17:48:34 +0000 (+0900) Subject: include/opt: Remove unnecessary array __opt_long X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=9cd91f5ef4c0030e0138f3f496d29d6d18c21c64;p=toolbox include/opt: Remove unnecessary array __opt_long The data that is stored in opt's __opt_long array is a subset of the data stored in __opt_map. The operations that the module does on __opt_long might just as well be performed on __opt_map without affecting the behavior of the module. This commit removes the __opt_long array from the module and changes the affected functions to use __opt_map instead. --- diff --git a/include/opt.sh b/include/opt.sh index d9c596a..f2bb6ad 100644 --- a/include/opt.sh +++ b/include/opt.sh @@ -30,7 +30,6 @@ __init() { ) declare -Axg __opt_short - declare -Axg __opt_long declare -Axg __opt_desc declare -Axg __opt_flags declare -Axg __opt_value @@ -114,7 +113,6 @@ opt_add_arg() { fi __opt_short["$long"]="$short" - __opt_long["$short"]="$long" __opt_flags["$long"]="$parsed_flags" __opt_desc["$long"]="$desc" __opt_regex["$long"]="$regex" @@ -151,7 +149,7 @@ opt_print_help() { local long local desc - long="${__opt_long[$short]}" + long="${__opt_map[-$short]}" desc="${__opt_desc[$long]}" printf "\t-%s\t--%s\t%s\n" \