scripts/config | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
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>
---
Changes in v2:
Specified the script name in the commit message.
scripts/config | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/scripts/config b/scripts/config
index ff88e2faefd3..ea475c07de28 100755
--- a/scripts/config
+++ b/scripts/config
@@ -32,6 +32,7 @@ commands:
Disable option directly after other option
--module-after|-M beforeopt option
Turn option into module directly after other option
+ --refresh Refresh the config using old settings
commands can be repeated multiple times
@@ -124,16 +125,22 @@ undef_var() {
txt_delete "^# $name is not set" "$FN"
}
-if [ "$1" = "--file" ]; then
- FN="$2"
- if [ "$FN" = "" ] ; then
- usage
+FN=.config
+CMDS=()
+while [[ $# -gt 0 ]]; do
+ if [ "$1" = "--file" ]; then
+ if [ "$2" = "" ]; then
+ usage
+ fi
+ FN="$2"
+ shift 2
+ else
+ CMDS+=("$1")
+ shift
fi
- shift 2
-else
- FN=.config
-fi
+done
+set -- "${CMDS[@]}"
if [ "$1" = "" ] ; then
usage
fi
@@ -217,9 +224,8 @@ while [ "$1" != "" ] ; do
set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
;;
- # undocumented because it ignores --file (fixme)
--refresh)
- yes "" | make oldconfig
+ yes "" | make oldconfig KCONFIG_CONFIG=$FN
;;
*)
--
2.48.1
On Sun, Mar 2, 2025 at 7:20 AM Seyediman Seyedarab <imandevel@gmail.com> wrote:
>
> 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>
> ---
Applied to linux-kbuild.
Thanks.
> Changes in v2:
> Specified the script name in the commit message.
>
> scripts/config | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/config b/scripts/config
> index ff88e2faefd3..ea475c07de28 100755
> --- a/scripts/config
> +++ b/scripts/config
> @@ -32,6 +32,7 @@ commands:
> Disable option directly after other option
> --module-after|-M beforeopt option
> Turn option into module directly after other option
> + --refresh Refresh the config using old settings
>
> commands can be repeated multiple times
>
> @@ -124,16 +125,22 @@ undef_var() {
> txt_delete "^# $name is not set" "$FN"
> }
>
> -if [ "$1" = "--file" ]; then
> - FN="$2"
> - if [ "$FN" = "" ] ; then
> - usage
> +FN=.config
> +CMDS=()
> +while [[ $# -gt 0 ]]; do
> + if [ "$1" = "--file" ]; then
> + if [ "$2" = "" ]; then
> + usage
> + fi
> + FN="$2"
> + shift 2
> + else
> + CMDS+=("$1")
> + shift
> fi
> - shift 2
> -else
> - FN=.config
> -fi
> +done
>
> +set -- "${CMDS[@]}"
> if [ "$1" = "" ] ; then
> usage
> fi
> @@ -217,9 +224,8 @@ while [ "$1" != "" ] ; do
> set_var "${CONFIG_}$B" "${CONFIG_}$B=m" "${CONFIG_}$A"
> ;;
>
> - # undocumented because it ignores --file (fixme)
> --refresh)
> - yes "" | make oldconfig
> + yes "" | make oldconfig KCONFIG_CONFIG=$FN
> ;;
>
> *)
> --
> 2.48.1
>
--
Best Regards
Masahiro Yamada
© 2016 - 2026 Red Hat, Inc.