build: sed portability fixes
Recently generating the version-def.h file and the config-list.h file have been updated, which broke versions of "sed" that do not want to be fed a file that ends with an incomplete line, and/or that do not understand the more recent "-E" option to use extended regular expression.
Fix them in response to a build-failure reported on Solaris boxes.
cf. https://lore.kernel.org/git/[email protected]/
---
* This time with a proposed log message. I may fast-track it down to 'master' before the release. I personally am undecided, and I do know that I hate the style of this particular sed script and am tempted to fix it before committing, but I'll refrain from doing so before the release.
GIT-VERSION-GEN | 2 +- generate-configlist.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
GIT-VERSION-GEN +1 -1
@@ -82,7 +82,7 @@ read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail $(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ') EOF -REPLACED=$(printf "%s" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ +REPLACED=$(printf "%s\n" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ -e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \ -e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \ -e "s|@GIT_MICRO_VERSION@|$GIT_MICRO_VERSION|" \
generate-configlist.sh +4 -4
@@ -13,16 +13,16 @@ print_config_list () { cat <<EOF static const char *config_name_list[] = { EOF - sed -E ' -/^`?[a-zA-Z].*\..*`?::$/ { + sed -e ' + /^`*[a-zA-Z].*\..*`*::$/ { /deprecated/d; s/::$//; s/`//g; s/^.*$/ "&",/; p;}; -d' \ + d' \ "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc| + "$SOURCE_DIR"/Documentation/config/*.adoc | sort cat <<EOF NULL,
Signature · 1 line
2.50.0-rc2-215-g56f75d5edf
Quoted 5 lines · Junio C Hamano
* This time with a proposed log message. I may fast-track it down to 'master' before the release. I personally am undecided, and I do know that I hate the style of this particular sed script and am tempted to fix it before committing, but I'll refrain from doing so before the release.
The newline-less input is in v2.49.0 already, but the use of "sed -E" is new in the 2.50 cycle. So it probably is worth addressing before the release. In which case I tried to give the patch a very careful read to avoid any brown paper bags.
GIT-VERSION-GEN read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail · line 88
Quoted 13 lines
GIT-VERSION-GEN +1
-1@@ -82,7 +82,7 @@ read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail $(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ') EOF -REPLACED=$(printf "%s" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ +REPLACED=$(printf "%s\n" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ -e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \ -e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \ -e "s|@GIT_MICRO_VERSION@|$GIT_MICRO_VERSION|" \
OK, makes sense since we now stick the content into the INPUT variable. That sometimes comes from a file, but we get it via process substitution with $(cat), so the shell will strip off the trailing newline there. So we can unconditionally add it back here. Goo.d
generate-configlist.sh print_config_list () { · line 17
Quoted 12 lines
generate-configlist.sh +2
-2@@ -13,16 +13,16 @@ print_config_list () { cat <<EOF static const char *config_name_list[] = { EOF - sed -E ' -/^`?[a-zA-Z].*\..*`?::$/ { + sed -e ' + /^`*[a-zA-Z].*\..*`*::$/ {
OK, this is just replacing the use of "?" with "*". I think it is OK to be loose here, as we are parsing our own config docs. And if somebody did write
```foo.bar```::
it is probably OK to parse that anyway. ;)
generate-configlist.sh print_config_list () { · line 25
Quoted 5 lines
generate-configlist.sh +2
-2-d' \ + d' \ "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc| + "$SOURCE_DIR"/Documentation/config/*.adoc |
And then this (plus the indentation above) is just non-semantic whitespace tidying.
So the whole thing looks good to me.
-Peff
Quoted 8 lines · Jeff King
Quoted 5 lines · Junio C Hamano
* This time with a proposed log message. I may fast-track it down to 'master' before the release. I personally am undecided, and I do know that I hate the style of this particular sed script and am tempted to fix it before committing, but I'll refrain from doing so before the release.
Quoted 4 lines
The newline-less input is in v2.49.0 already, but the use of "sed -E" is new in the 2.50 cycle. So it probably is worth addressing before the release. In which case I tried to give the patch a very careful read to avoid any brown paper bags.
Yeah, I could split them into two patches, but I do not think it is worth keeping one half broken for the sake of being bug-to-bug compatible with a previous version in this case.
Quoted 8 lines
Quoted 8 lines
GIT-VERSION-GEN +0
-0@@ -82,7 +82,7 @@ read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail $(echo "$GIT_VERSION" 0 0 0 0 | tr '.a-zA-Z-' ' ') EOF
Quoted 10 lines
GIT-VERSION-GEN read GIT_MAJOR_VERSION GIT_MINOR_VERSION GIT_MICRO_VERSION GIT_PATCH_LEVEL trail · line 88
Quoted 5 lines
GIT-VERSION-GEN +1
-1-REPLACED=$(printf "%s" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ +REPLACED=$(printf "%s\n" "$INPUT" | sed -e "s|@GIT_VERSION@|$GIT_VERSION|" \ -e "s|@GIT_MAJOR_VERSION@|$GIT_MAJOR_VERSION|" \ -e "s|@GIT_MINOR_VERSION@|$GIT_MINOR_VERSION|" \ -e "s|@GIT_MICRO_VERSION@|$GIT_MICRO_VERSION|" \OK, makes sense since we now stick the content into the INPUT variable. That sometimes comes from a file, but we get it via process substitution with $(cat), so the shell will strip off the trailing newline there. So we can unconditionally add it back here. Goo.d
Yup, the commit that introduced this sprinkled the same 'printf "%s\n" used as a better/safer version of echo, feeding a pipe' pattern and this I think is merely a typo.
Quoted 7 lines
Quoted 7 lines
generate-configlist.sh +0
-0@@ -13,16 +13,16 @@ print_config_list () { cat <<EOF static const char *config_name_list[] = {
Quoted 8 lines
generate-configlist.sh print_config_list () { · line 17
Quoted 5 lines
generate-configlist.sh +2
-2EOF - sed -E ' -/^`?[a-zA-Z].*\..*`?::$/ { + sed -e ' + /^`*[a-zA-Z].*\..*`*::$/ {OK, this is just replacing the use of "?" with "*". I think it is OK to be loose here, as we are parsing our own config docs.
Exactly. Similar reasoning appears in the precursor of this patch, i.e. https://lore.kernel.org/git/[email protected]/
Quoted 6 lines
And if somebody
did write```foo.bar```::
it is probably OK to parse that anyway. ;)
probably ;-).
Quoted 10 lines
generate-configlist.sh print_config_list () { · line 25
Quoted 5 lines
generate-configlist.sh +2
-2-d' \ + d' \ "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc| + "$SOURCE_DIR"/Documentation/config/*.adoc |And then this (plus the indentation above) is just non-semantic whitespace tidying.
So the whole thing looks good to me.
Thanks.
Will fast-track.