[PATCHv2 4/4] base-files/functions.sh: quote variables in []
Rosen Penev
rosenp at gmail.com
Thu Oct 15 01:58:27 EDT 2020
ash does not support [[]] syntax, which makes this redundant.
Found with https://github.com/koalaman/shellcheck/wiki/Sc2086
Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
package/base-files/files/lib/functions.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 598e283b1e..b91508c04c 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -92,7 +92,7 @@ list() {
local len
config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0
- [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
+ [ "$len" = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}"
len=$((len + 1))
config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value"
config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len"
@@ -164,7 +164,7 @@ config_list_foreach() {
config_get len "${section}" "${option}_LENGTH"
[ -z "$len" ] && return 0
- while [ $c -le "$len" ]; do
+ while [ "$c" -le "$len" ]; do
config_get val "${section}" "${option}_ITEM$c"
eval "$function \"\$val\" \"\$@\""
c="$((c + 1))"
--
2.17.1
More information about the openwrt-devel
mailing list