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

mail at adrianschmutzler.de mail at adrianschmutzler.de
Sat Jan 18 10:40:59 EST 2020


Hi,

> -----Original Message-----
> From: openwrt-devel [mailto:openwrt-devel-bounces at lists.openwrt.org]
> On Behalf Of Rosen Penev
> Sent: Freitag, 17. Januar 2020 05:44
> To: openwrt-devel at lists.openwrt.org
> Subject: [OpenWrt-Devel] [PATCH 6/7] base-files/functions.sh: do not
> iterate over ls
> 
> 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

I personally think this command flow is counter-intuitive (having to filter the pattern if no file is found).

I prefer the ls version and would reject that one unless somebody else likes it (and says so until Monday).

Nevertheless, thanks for caring.

Best

Adrian 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20200118/83335979/attachment.sig>
-------------- next part --------------
_______________________________________________
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