Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline
@ 2024-08-02 12:42 Anders Roxell
  2024-08-03 14:25 ` Masahiro Yamada
  2024-08-05  9:22 ` [PATCH v2] " Anders Roxell
  0 siblings, 2 replies; 5+ messages in thread
From: Anders Roxell @ 2024-08-02 12:42 UTC (permalink / raw)
  To: masahiroy; +Cc: linux-kbuild, linux-kernel, Anders Roxell

When merging files without trailing newlines a the end of the file, two
config fragments end up at the same row if file1.config doens't have a
trailing newline at the end of the file.

file1.config "CONFIG_1=y"
file2.config "CONFIG_2=y"
./scripts/kconfig/merge_config.sh -m .config file1.config file2.config

this will generate a .config lookingn like this.
cat .config
...
CONFIG_1=yCONFIG_2=y"

Making sure so we add a newline at the end of every config file that is
passed into the script.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 scripts/kconfig/merge_config.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index 902eb429b9db..ce1b77ee043b 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -136,7 +136,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
 		echo "The merge file '$ORIG_MERGE_FILE' does not exist.  Exit." >&2
 		exit 1
 	fi
-	cat $ORIG_MERGE_FILE > $MERGE_FILE
+	cat $ORIG_MERGE_FILE | sed -e '$a\' > $MERGE_FILE
 	CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE)
 
 	for CFG in $CFG_LIST ; do
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline
  2024-08-02 12:42 [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline Anders Roxell
@ 2024-08-03 14:25 ` Masahiro Yamada
  2024-08-05  9:21   ` Anders Roxell
  2024-08-05  9:22 ` [PATCH v2] " Anders Roxell
  1 sibling, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2024-08-03 14:25 UTC (permalink / raw)
  To: Anders Roxell; +Cc: linux-kbuild, linux-kernel

On Fri, Aug 2, 2024 at 9:42 PM Anders Roxell <anders.roxell@linaro.org> wrote:
>
> When merging files without trailing newlines a the end of the file, two
> config fragments end up at the same row if file1.config doens't have a
> trailing newline at the end of the file.
>
> file1.config "CONFIG_1=y"
> file2.config "CONFIG_2=y"
> ./scripts/kconfig/merge_config.sh -m .config file1.config file2.config
>
> this will generate a .config lookingn like this.
> cat .config
> ...
> CONFIG_1=yCONFIG_2=y"
>
> Making sure so we add a newline at the end of every config file that is
> passed into the script.
>
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---
>  scripts/kconfig/merge_config.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
> index 902eb429b9db..ce1b77ee043b 100755
> --- a/scripts/kconfig/merge_config.sh
> +++ b/scripts/kconfig/merge_config.sh
> @@ -136,7 +136,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
>                 echo "The merge file '$ORIG_MERGE_FILE' does not exist.  Exit." >&2
>                 exit 1
>         fi
> -       cat $ORIG_MERGE_FILE > $MERGE_FILE
> +       cat $ORIG_MERGE_FILE | sed -e '$a\' > $MERGE_FILE


Is the pipe necessary? This seems to be equivalent to:

  sed -e '$a\' $ORIG_MERGE_FILE > $MERGE_FILE






This issue also happens if $INITFILE lacks a newline at the end.


I think the right place to insert a line is there:


        # In case the previous file lacks a new line at the end
        echo >> $TMP_FILE
        cat $MERGE_FILE >> $TMP_FILE


I am fine with always inserting a line between files.




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline
  2024-08-03 14:25 ` Masahiro Yamada
@ 2024-08-05  9:21   ` Anders Roxell
  0 siblings, 0 replies; 5+ messages in thread
From: Anders Roxell @ 2024-08-05  9:21 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel

On Sat, 3 Aug 2024 at 16:26, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Fri, Aug 2, 2024 at 9:42 PM Anders Roxell <anders.roxell@linaro.org> wrote:
> >
> > When merging files without trailing newlines a the end of the file, two
> > config fragments end up at the same row if file1.config doens't have a
> > trailing newline at the end of the file.
> >
> > file1.config "CONFIG_1=y"
> > file2.config "CONFIG_2=y"
> > ./scripts/kconfig/merge_config.sh -m .config file1.config file2.config
> >
> > this will generate a .config lookingn like this.
> > cat .config
> > ...
> > CONFIG_1=yCONFIG_2=y"
> >
> > Making sure so we add a newline at the end of every config file that is
> > passed into the script.
> >
> > Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> > ---
> >  scripts/kconfig/merge_config.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
> > index 902eb429b9db..ce1b77ee043b 100755
> > --- a/scripts/kconfig/merge_config.sh
> > +++ b/scripts/kconfig/merge_config.sh
> > @@ -136,7 +136,7 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
> >                 echo "The merge file '$ORIG_MERGE_FILE' does not exist.  Exit." >&2
> >                 exit 1
> >         fi
> > -       cat $ORIG_MERGE_FILE > $MERGE_FILE
> > +       cat $ORIG_MERGE_FILE | sed -e '$a\' > $MERGE_FILE
>
>
> Is the pipe necessary? This seems to be equivalent to:
>
>   sed -e '$a\' $ORIG_MERGE_FILE > $MERGE_FILE
>
>
>
>
>
>
> This issue also happens if $INITFILE lacks a newline at the end.
>
>
> I think the right place to insert a line is there:
>
>
>         # In case the previous file lacks a new line at the end
>         echo >> $TMP_FILE
>         cat $MERGE_FILE >> $TMP_FILE
>
>
> I am fine with always inserting a line between files.

Thank you Masahiro for your review.
Sending a v2 shortly.

Cheers,
Anders

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] scripts: kconfig: merge_config: config files: add a trailing newline
  2024-08-02 12:42 [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline Anders Roxell
  2024-08-03 14:25 ` Masahiro Yamada
@ 2024-08-05  9:22 ` Anders Roxell
  2024-08-06  5:34   ` Masahiro Yamada
  1 sibling, 1 reply; 5+ messages in thread
From: Anders Roxell @ 2024-08-05  9:22 UTC (permalink / raw)
  To: masahiroy; +Cc: linux-kbuild, linux-kernel, Anders Roxell

When merging files without trailing newlines at the end of the file, two
config fragments end up at the same row if file1.config doens't have a
trailing newline at the end of the file.

file1.config "CONFIG_1=y"
file2.config "CONFIG_2=y"
./scripts/kconfig/merge_config.sh -m .config file1.config file2.config

This will generate a .config looking like this.
cat .config
...
CONFIG_1=yCONFIG_2=y"

Making sure so we add a newline at the end of every config file that is
passed into the script.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 scripts/kconfig/merge_config.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
index 902eb429b9db..0b7952471c18 100755
--- a/scripts/kconfig/merge_config.sh
+++ b/scripts/kconfig/merge_config.sh
@@ -167,6 +167,8 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
 			sed -i "/$CFG[ =]/d" $MERGE_FILE
 		fi
 	done
+	# In case the previous file lacks a new line at the end
+	echo >> $TMP_FILE
 	cat $MERGE_FILE >> $TMP_FILE
 done
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] scripts: kconfig: merge_config: config files: add a trailing newline
  2024-08-05  9:22 ` [PATCH v2] " Anders Roxell
@ 2024-08-06  5:34   ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2024-08-06  5:34 UTC (permalink / raw)
  To: Anders Roxell; +Cc: linux-kbuild, linux-kernel

On Mon, Aug 5, 2024 at 6:22 PM Anders Roxell <anders.roxell@linaro.org> wrote:
>
> When merging files without trailing newlines at the end of the file, two
> config fragments end up at the same row if file1.config doens't have a
> trailing newline at the end of the file.
>
> file1.config "CONFIG_1=y"
> file2.config "CONFIG_2=y"
> ./scripts/kconfig/merge_config.sh -m .config file1.config file2.config
>
> This will generate a .config looking like this.
> cat .config
> ...
> CONFIG_1=yCONFIG_2=y"
>
> Making sure so we add a newline at the end of every config file that is
> passed into the script.
>
> Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
> ---


Applied to linux-kbuild/fixes.
Thanks.


>  scripts/kconfig/merge_config.sh | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh
> index 902eb429b9db..0b7952471c18 100755
> --- a/scripts/kconfig/merge_config.sh
> +++ b/scripts/kconfig/merge_config.sh
> @@ -167,6 +167,8 @@ for ORIG_MERGE_FILE in $MERGE_LIST ; do
>                         sed -i "/$CFG[ =]/d" $MERGE_FILE
>                 fi
>         done
> +       # In case the previous file lacks a new line at the end
> +       echo >> $TMP_FILE
>         cat $MERGE_FILE >> $TMP_FILE
>  done
>
> --
> 2.43.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-06  5:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-02 12:42 [PATCH] scripts: kconfig: merge_config: config files: add a trailing newline Anders Roxell
2024-08-03 14:25 ` Masahiro Yamada
2024-08-05  9:21   ` Anders Roxell
2024-08-05  9:22 ` [PATCH v2] " Anders Roxell
2024-08-06  5:34   ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox