From 9cd91f5ef4c0030e0138f3f496d29d6d18c21c64 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Fri, 12 Aug 2022 02:48:34 +0900 Subject: [PATCH] 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. --- include/opt.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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" \ -- 2.47.3