[OpenWrt-Devel] [PATCH 6/7] base-files/functions.sh: do not iterate over ls

Rosen Penev rosenp at gmail.com
Thu Jan 16 23:43:58 EST 2020


It does word splitting and glob expansion, which is undesirable.

https://github.com/koalaman/shellcheck/wiki/SC2045

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 package/base-files/files/lib/functions.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 82a2169260..048bfd2b2a 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -283,7 +283,8 @@ default_postinst() {
 include() {
 	local file
 
-	for file in $(ls $1/*.sh 2>/dev/null); do
+	for file in "$1"/*.sh; do
+		[ -e "$file" ] || break
 		. $file
 	done
 }
-- 
2.24.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list