Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: fix argument parsing in scripts/config

The script previously assumed --file was always the first argument,
which caused issues when it appeared later. This patch updates the
parsing logic to scan all arguments to find --file, sets the config
file correctly, and resets the argument list with the remaining
commands.

It also fixes --refresh to respect --file by passing KCONFIG_CONFIG=$FN
to make oldconfig.

Signed-off-by: Seyediman Seyedarab <imandevel@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Seyediman Seyedarab and committed by
Masahiro Yamada
f757f601 82c09de2

+16 -10
+16 -10
scripts/config
··· 32 32 Disable option directly after other option 33 33 --module-after|-M beforeopt option 34 34 Turn option into module directly after other option 35 + --refresh Refresh the config using old settings 35 36 36 37 commands can be repeated multiple times 37 38 ··· 125 124 txt_delete "^# $name is not set" "$FN" 126 125 } 127 126 128 - if [ "$1" = "--file" ]; then 129 - FN="$2" 130 - if [ "$FN" = "" ] ; then 131 - usage 127 + FN=.config 128 + CMDS=() 129 + while [[ $# -gt 0 ]]; do 130 + if [ "$1" = "--file" ]; then 131 + if [ "$2" = "" ]; then 132 + usage 133 + fi 134 + FN="$2" 135 + shift 2 136 + else 137 + CMDS+=("$1") 138 + shift 132 139 fi 133 - shift 2 134 - else 135 - FN=.config 136 - fi 140 + done 137 141 142 + set -- "${CMDS[@]}" 138 143 if [ "$1" = "" ] ; then 139 144 usage 140 145 fi ··· 224 217 set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" 225 218 ;; 226 219 227 - # undocumented because it ignores --file (fixme) 228 220 --refresh) 229 - yes "" | make oldconfig 221 + yes "" | make oldconfig KCONFIG_CONFIG=$FN 230 222 ;; 231 223 232 224 *)