2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

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>
This commit is contained in:
Seyediman Seyedarab 2025-03-01 17:21:37 -05:00 committed by Masahiro Yamada
parent 82c09de2d4
commit f757f6011c

View File

@ -32,6 +32,7 @@ commands:
Disable option directly after other option Disable option directly after other option
--module-after|-M beforeopt option --module-after|-M beforeopt option
Turn option into module directly after other option Turn option into module directly after other option
--refresh Refresh the config using old settings
commands can be repeated multiple times commands can be repeated multiple times
@ -124,16 +125,22 @@ undef_var() {
txt_delete "^# $name is not set" "$FN" txt_delete "^# $name is not set" "$FN"
} }
if [ "$1" = "--file" ]; then FN=.config
FN="$2" CMDS=()
if [ "$FN" = "" ] ; then while [[ $# -gt 0 ]]; do
if [ "$1" = "--file" ]; then
if [ "$2" = "" ]; then
usage usage
fi fi
FN="$2"
shift 2 shift 2
else else
FN=.config CMDS+=("$1")
fi shift
fi
done
set -- "${CMDS[@]}"
if [ "$1" = "" ] ; then if [ "$1" = "" ] ; then
usage usage
fi fi
@ -217,9 +224,8 @@ while [ "$1" != "" ] ; do
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A" set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
;; ;;
# undocumented because it ignores --file (fixme)
--refresh) --refresh)
yes "" | make oldconfig yes "" | make oldconfig KCONFIG_CONFIG=$FN
;; ;;
*) *)