ddns-scripts: refactor load_all_config_options()
authorPaul Donald <[email protected]>
Sat, 30 Nov 2024 15:46:08 +0000 (16:46 +0100)
committerFlorian Eckert <[email protected]>
Thu, 10 Apr 2025 07:34:38 +0000 (09:34 +0200)
Same functionality - code reads less 'shouty' and 'stabby'.

Signed-off-by: Paul Donald <[email protected]>
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh

index cb8423190695d1cc91beeddde00fdda1445d6b35..d64ad8c26b251953c6bedde12420b1ac68c89cac 100644 (file)
@@ -129,35 +129,34 @@ USE_CURL=$(uci -q get ddns.global.use_curl) || USE_CURL=0 # read config
 # $1 = ddns, $2 = SECTION_ID
 load_all_config_options()
 {
-       local __PKGNAME="$1"
-       local __SECTIONID="$2"
-       local __VAR
-       local __ALL_OPTION_VARIABLES=""
+       local pkg_name section_id tmp_var all_opt_vars
+       pkg_name="$1"
+       section_id="$2"
 
-       # this callback loads all the variables in the __SECTIONID section when we do
+       # this callback loads all the variables in the $section_id section when we do
        # config_load. We need to redefine the option_cb for different sections
        # so that the active one isn't still active after we're done with it.  For reference
        # the $1 variable is the name of the option and $2 is the name of the section
        config_cb()
        {
-               if [ ."$2" = ."$__SECTIONID" ]; then
+               if [ ."$2" = ."$section_id" ]; then
                        option_cb()
                        {
-                               __ALL_OPTION_VARIABLES="$__ALL_OPTION_VARIABLES $1"
+                               all_opt_vars="$all_opt_vars $1"
                        }
                else
                        option_cb() { return 0; }
                fi
        }
 
-       config_load "$__PKGNAME"
+       config_load "$pkg_name"
 
        # Given SECTION_ID not found so no data, so return 1
-       [ -z "$__ALL_OPTION_VARIABLES" ] && return 1
+       [ -z "$all_opt_vars" ] && return 1
 
-       for __VAR in $__ALL_OPTION_VARIABLES
+       for tmp_var in $all_opt_vars
        do
-               config_get "$__VAR" "$__SECTIONID" "$__VAR"
+               config_get "$tmp_var" "$section_id" "$tmp_var"
        done
        return 0
 }