scripts: kconfig: merge_config: config files: add a trailing newline
PATCH 1/1 scripts: kconfig: merge_config: config files: add a trailing newline
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.
--- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/merge_config.sh +1 -1
@@ -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
Signature · 1 line
2.43.0
Quoted 27 lines · 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.configthis 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 <[email protected]>--- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/kconfig/merge_config.sh +0
-0
scripts/kconfig/merge_config.sh for ORIG_MERGE_FILE in $MERGE_LIST ; do · line 139
Quoted 5 lines
scripts/kconfig/merge_config.sh +1
-1@@ -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.
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 51 lines · Masahiro Yamada
Quoted 27 lines · 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.configthis 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 <[email protected]>--- scripts/kconfig/merge_config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/kconfig/merge_config.sh +0
-0scripts/kconfig/merge_config.sh for ORIG_MERGE_FILE in $MERGE_LIST ; do · line 139
Quoted 5 lines
scripts/kconfig/merge_config.sh +1
-1@@ -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_FILEIs 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:
Quoted 6 lines
# In case the previous file lacks a new line at the end echo >> $TMP_FILE
cat $MERGE_FILE >> $TMP_FILEI am fine with always inserting a line between files.
Thank you Masahiro for your review.
Sending a v2 shortly.
Cheers,
Anders
PATCH v2 1/1 scripts: kconfig: merge_config: config files: add a trailing newline
In reply to Anders RoxellWhen 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.
--- scripts/kconfig/merge_config.sh | 2 ++ 1 file changed, 2 insertions(+)
scripts/kconfig/merge_config.sh +2 -0
@@ -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
Signature · 1 line
2.43.0
Quoted 14 lines · 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.configThis will generate a .config looking like this.
cat .config
...CONFIG_1=yCONFIG_2=y"
Quoted 5 lines
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 <[email protected]>---
Applied to linux-kbuild/fixes.
Thanks.
Quoted 19 lines
scripts/kconfig/merge_config.sh | 2 ++ 1 file changed, 2 insertions(+)scripts/kconfig/merge_config.sh +2
-1@@ -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
Signature · 2 lines
Best Regards Masahiro Yamada