[OpenWrt-Devel] [PATCH] build: fix STAGING_DIR cleaning when filenames contain spaces

Petr Štetiar ynezz at true.cz
Fri May 3 02:39:59 PDT 2019


Jeffery To <jeffery.to at gmail.com> [2019-05-03 01:33:27]:

> When looping through a package's STAGING_FILES_LIST (a list of
> file/directory paths delimited by newlines), if the path contains
> spaces, then the path will be split by the while loops, and the
> file/directory will not be deleted/removed.
> 
> This sets the internal field separator to the newline only so that the
> entire path is considered when deleting/removing.
> 
> Signed-off-by: Jeffery To <jeffery.to at gmail.com>
> ---
>  scripts/clean-package.sh | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/scripts/clean-package.sh b/scripts/clean-package.sh
> index e580566a52..3a824929c6 100755
> --- a/scripts/clean-package.sh
> +++ b/scripts/clean-package.sh
> @@ -1,4 +1,6 @@
>  #!/usr/bin/env bash
> +IFS="
> +"
>  [ -n "$1" -a -n "$2" ] || {
>  	echo "Usage: $0 <file> <directory>"
>  	exit 1

just for the record, copy&pasting my comment from your PR[1]:

I'm just wondering, if this proposed fix with this strange looking IFS is the
right direction. Usually if I've problem with whitespaces in filenames, it's
because I've forget to use xargs. If I'm not mistaken, this [ -n "$entry" ] ||
break construct could be replaced with xargs -r, there's even XARGS:=xargs -r
in rules.mk. Just my two cents.

1. https://github.com/openwrt/openwrt/pull/1806#issuecomment-475454138

-- ynezz



More information about the openwrt-devel mailing list