[PATCH 4/4] base-files/functions.sh: quote variables in []

Rosen Penev rosenp at gmail.com
Sun Sep 20 01:31:40 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 a7ff50cb1a..8ada3c376a 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.26.2




More information about the openwrt-devel mailing list