[lkml]   [2019]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH] initramfs: fix 'bad variable name' error in
I was looking at this, and in theory there are other problems that
could arise from non-escaped characters, or things with leading
hyphens... In general it isn't great to assume ls output will play
nicely with the internal field separator / IFS. I think a better
solution would be to use something like ${foo@Q} and instead of trying
to scrape ls -l, maybe using stat, since it can be asked to print out
the device number.

But I don't think this patch fixes the problem mentioned at all-- I
think the problem is initfs is not a variable name on line 61:

$(call if_changed,initfs)

The Makefile and script look like more patches would be needed to fix
mentioned issue, and I'm kind of wondering what the intent behind
lines 31-32 is...

ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
$(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)

why filter nothing, why shell echo?

Quoting and/or proper escaping would be needed in many other places,
and I suspect cpio input is always regenerated... The use of sed to
manually escape things and suggesting using \ instead of using the
argument terminator "--"... If weird paths with spaces and stuff are a
requirement for the script needs some overhauling

On Mon, Dec 30, 2019 at 5:21 AM Masahiro Yamada <> wrote:
> Prior to commit 858805b336be ("kbuild: add $(BASH) to run scripts with
> bash-extension"), this shell script was almost always run by bash since
> bash is usually installed on the system by default.
> Now, this script is run by sh, which might be a symlink to dash. On such
> distros, the following code emits an error:
> local dev=`LC_ALL=C ls -l "${location}"`
> You can reproduce the build error, for example by setting
> GEN usr/initramfs_data.cpio.gz
> ./usr/ 131: local: 1: bad variable name
> make[1]: *** [usr/Makefile:61: usr/initramfs_data.cpio.gz] Error 2
> This is because `LC_ALL=C ls -l "${location}"` contains spaces.
> Surrounding it with double-quotes fixes the error.
> Fixes: 858805b336be ("kbuild: add $(BASH) to run scripts with bash-extension")
> Reported-by: Jory A. Pratt <>
> Signed-off-by: Masahiro Yamada <>
> ---
> usr/ | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/usr/ b/usr/
> index 0aad760fcd8c..2bbac73e6477 100755
> --- a/usr/
> +++ b/usr/
> @@ -128,7 +128,7 @@ parse() {
> str="${ftype} ${name} ${location} ${str}"
> ;;
> "nod")
> - local dev=`LC_ALL=C ls -l "${location}"`
> + local dev="`LC_ALL=C ls -l "${location}"`"
> local maj=`field 5 ${dev}`
> local min=`field 6 ${dev}`
> maj=${maj%,}
> --
> 2.17.1

 \ /
  Last update: 2019-12-30 16:14    [W:0.031 / U:1.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site