[PATCH 2/4] base-files/functions.sh: do not iterate over ls

edgar.soldin at web.de edgar.soldin at web.de
Sun Sep 20 06:12:24 EDT 2020


On 20.09.2020 07:31, Rosen Penev wrote:
> -	for file in $(ls $1/*.sh 2>/dev/null); do
> -		. $file
> +	for file in "$1"/*.sh; do
> +		[ -e "$file" ] || break
> +		. "$file"

the existence check is probably meant to catch "../*.sh" entry found if no files match. as files will likely not vanish during the loop this will probably work.
still it'll break the loop completely without any need. using 'continue' instead of 'break' would not break the loop and be safer here.

..ede



More information about the openwrt-devel mailing list