[PATCH 2/4] base-files/functions.sh: do not iterate over ls
Rosen Penev
rosenp at gmail.com
Sun Sep 20 01:31:38 EDT 2020
>From https://github.com/koalaman/shellcheck/wiki/SC2045 :
When looping over a set of files, it's always better to use globs when
possible. Using command expansion causes word splitting and glob
expansion, which will cause problems for certain filenames (typically
first seen when trying to process a file with spaces in the name).
Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
package/base-files/files/lib/functions.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 59bb0fe711..0f56387244 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -290,8 +290,9 @@ default_postinst() {
include() {
local file
- for file in $(ls $1/*.sh 2>/dev/null); do
- . $file
+ for file in "$1"/*.sh; do
+ [ -e "$file" ] || break
+ . "$file"
done
}
--
2.26.2
More information about the openwrt-devel
mailing list