Skip to content

Commit f757f60

Browse files
ImanSeyedmasahir0y
authored andcommitted
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 <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 82c09de commit f757f60

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

scripts/config

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ commands:
3232
Disable option directly after other option
3333
--module-after|-M beforeopt option
3434
Turn option into module directly after other option
35+
--refresh Refresh the config using old settings
3536
3637
commands can be repeated multiple times
3738
@@ -124,16 +125,22 @@ undef_var() {
124125
txt_delete "^# $name is not set" "$FN"
125126
}
126127

127-
if [ "$1" = "--file" ]; then
128-
FN="$2"
129-
if [ "$FN" = "" ] ; then
130-
usage
128+
FN=.config
129+
CMDS=()
130+
while [[ $# -gt 0 ]]; do
131+
if [ "$1" = "--file" ]; then
132+
if [ "$2" = "" ]; then
133+
usage
134+
fi
135+
FN="$2"
136+
shift 2
137+
else
138+
CMDS+=("$1")
139+
shift
131140
fi
132-
shift 2
133-
else
134-
FN=.config
135-
fi
141+
done
136142

143+
set -- "${CMDS[@]}"
137144
if [ "$1" = "" ] ; then
138145
usage
139146
fi
@@ -217,9 +224,8 @@ while [ "$1" != "" ] ; do
217224
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
218225
;;
219226

220-
# undocumented because it ignores --file (fixme)
221227
--refresh)
222-
yes "" | make oldconfig
228+
yes "" | make oldconfig KCONFIG_CONFIG=$FN
223229
;;
224230

225231
*)

0 commit comments

Comments
 (0)