Skip to content

Commit

Permalink
gen_initramfs_list.sh: fix 'bad variable name' error
Browse files Browse the repository at this point in the history
Prior to commit 858805b ("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
distributions, the following code emits an error:

  local dev=`LC_ALL=C ls -l "${location}"`

You can reproduce the build error, for example by setting
CONFIG_INITRAMFS_SOURCE="/dev".

    GEN     usr/initramfs_data.cpio.gz
  ./usr/gen_initramfs_list.sh: 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: 858805b ("kbuild: add $(BASH) to run scripts with bash-extension")
Reported-by: Jory A. Pratt <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
masahir0y committed Jan 3, 2020
1 parent 46cf053 commit cc97661
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion usr/gen_initramfs_list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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%,}
Expand Down

0 comments on commit cc97661

Please sign in to comment.