]> git.corax.cc Git - toolbox/commitdiff
include/opt: Work around bug in old bash versions
authorMatthias Kruk <matthias.kruk@miraclelinux.com>
Thu, 20 May 2021 00:55:14 +0000 (09:55 +0900)
committerMatthias Kruk <matthias.kruk@miraclelinux.com>
Thu, 20 May 2021 00:55:14 +0000 (09:55 +0900)
Declaring a non-local array and initializing it in the same statement
causes it to become local in older bash versions. This commit works
around this bug by removing the array initializations from internal
arrays of the opt module.

include/opt.sh

index a65450260585baebe00acb32b210055ef3930ca4..ea67f7f959cf9dd7425bf5c4f7ef7577d38cc606 100644 (file)
@@ -8,14 +8,14 @@ __init() {
        declare -xgir __opt_flag_required=1
        declare -xgir __opt_flag_has_value=2
 
-       declare -Axg __opt_short=()
-       declare -Axg __opt_long=()
-       declare -Axg __opt_desc=()
-       declare -Axg __opt_flags=()
-       declare -Axg __opt_value=()
-       declare -Axg __opt_default=()
-       declare -Axg __opt_action=()
-       declare -Axg __opt_map=()
+       declare -Axg __opt_short
+       declare -Axg __opt_long
+       declare -Axg __opt_desc
+       declare -Axg __opt_flags
+       declare -Axg __opt_value
+       declare -Axg __opt_default
+       declare -Axg __opt_action
+       declare -Axg __opt_map
        declare -xgi __opt_num=0
        declare -xgi __opt_longest=0