# Solaris sed

15 messages from 2025-06-12 to 2025-06-13. Participants: Brad Smith, Collin Funk, Junio C Hamano, Eli Schwartz, Eric Sunshine, Paul Smith, Jean-Noël AVILA.
Thread: https://gitlist.dev/t/63630

## Brad Smith, 2025-06-12 03:23

Subject: Solaris sed
Message-ID: <09f954b8-d9c3-418f-ad4b-9cb9b063f4ae@comstyle.com>
URL: https://gitlist.dev/e/09f954b8-d9c3-418f-ad4b-9cb9b063f4ae%40comstyle.com

```
Building on Solaris I noticed the following two issues with Solaris sed.

     GEN version-def.h
sed: Missing newline at end of file standard input.

     GEN config-list.h
sed: illegal option -- E
Usage:  sed [-n] script [file...]
         sed [-n] [-e script]...[-f script_file]...[file...]


https://github.com/git/git/commit/e1b81f54da80267edee2cb8fd0d0f75f03023019

The second issue being introduced fairly recently. Not sure what would be
appropriate fixes. Just pointing them out if someone has an suggestions for
fixes.


```

## Collin Funk, 2025-06-12 03:42

Subject: Re: Solaris sed
Message-ID: <87bjqteicd.fsf@gmail.com>
URL: https://gitlist.dev/e/87bjqteicd.fsf%40gmail.com
In-Reply-To: <09f954b8-d9c3-418f-ad4b-9cb9b063f4ae@comstyle.com>

```
Hi Brad,

Brad Smith <brad@comstyle.com> writes:

> Building on Solaris I noticed the following two issues with Solaris sed.
>
>     GEN version-def.h
> sed: Missing newline at end of file standard input.
>
>     GEN config-list.h
> sed: illegal option -- E
> Usage:  sed [-n] script [file...]
>         sed [-n] [-e script]...[-f script_file]...[file...]
>
>
> https://github.com/git/git/commit/e1b81f54da80267edee2cb8fd0d0f75f03023019
>
> The second issue being introduced fairly recently. Not sure what would be
> appropriate fixes. Just pointing them out if someone has an suggestions for
> fixes.

I noticed these as well, but just ignored them since it seems to build
fine.

The first one seems like just a warning? Probably something to do with
POSIX defining a "Text File" as "A file that contains characters
organized into zero or more lines" where a line is "A sequence of zero
or more non- <newline> characters plus a terminating <newline>
character."

The second is more tricky. The '-E' option to use EREs was not added to
the specification for 'sed' until POSIX.1-2024 [1]. Maybe the script
could check for the 'gsed' command? All of the (few) Solaris machines I
use will have many GNU programs installed like that.

Collin

[1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html

```

## Brad Smith, 2025-06-12 03:49

Subject: Re: Solaris sed
Message-ID: <f2082cde-7eb9-4927-a01c-e6fb3b355d13@comstyle.com>
URL: https://gitlist.dev/e/f2082cde-7eb9-4927-a01c-e6fb3b355d13%40comstyle.com
In-Reply-To: <87bjqteicd.fsf@gmail.com>

```
On 2025-06-11 11:42 p.m., Collin Funk wrote:
> Hi Brad,
>
> Brad Smith <brad@comstyle.com> writes:
>
>> Building on Solaris I noticed the following two issues with Solaris sed.
>>
>>      GEN version-def.h
>> sed: Missing newline at end of file standard input.
>>
>>      GEN config-list.h
>> sed: illegal option -- E
>> Usage:  sed [-n] script [file...]
>>          sed [-n] [-e script]...[-f script_file]...[file...]
>>
>>
>> https://github.com/git/git/commit/e1b81f54da80267edee2cb8fd0d0f75f03023019
>>
>> The second issue being introduced fairly recently. Not sure what would be
>> appropriate fixes. Just pointing them out if someone has an suggestions for
>> fixes.
> I noticed these as well, but just ignored them since it seems to build
> fine.
>
> The first one seems like just a warning? Probably something to do with
> POSIX defining a "Text File" as "A file that contains characters
> organized into zero or more lines" where a line is "A sequence of zero
> or more non- <newline> characters plus a terminating <newline>
> character."
It looks as if it is just a warning to me. I wasn't worrying about that 
one as much
as I was the second issue.
> The second is more tricky. The '-E' option to use EREs was not added to
> the specification for 'sed' until POSIX.1-2024 [1]. Maybe the script
> could check for the 'gsed' command? All of the (few) Solaris machines I
> use will have many GNU programs installed like that.
I can't comment on that especially as the build bits support pretty old 
releases and
I have no idea how long Sun / Oracle have been shipping GNU bits like 
this. I do not
believe this has always been a thing.
> Collin
>
> [1] https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html
>

```

## Junio C Hamano, 2025-06-12 04:03

Subject: Re: Solaris sed
Message-ID: <xmqqo6utfvxu.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqo6utfvxu.fsf%40gitster.g
In-Reply-To: <09f954b8-d9c3-418f-ad4b-9cb9b063f4ae@comstyle.com>

```
Brad Smith <brad@comstyle.com> writes:

> Building on Solaris I noticed the following two issues with Solaris sed.
>
>     GEN version-def.h
> sed: Missing newline at end of file standard input.

Perhaps it is this input line it is complaining about.  sed works on
text files, and a file that ends in incomplete line was not quite
text.

-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|" \

>     GEN config-list.h
> sed: illegal option -- E
> Usage:  sed [-n] script [file...]
>         sed [-n] [-e script]...[-f script_file]...[file...]

This is a bit trickier but should be doable.  It does not like the
-E option to use ERE (as opposed to BRE) for pattern matching used
in generate-configlist.sh script.

	sed -E '
	/^`?[a-zA-Z].*\..*`?::$/ {
	/deprecated/d;
	s/::$//;
	s/`//g;
	s/^.*$/	"&",/;
	p;};
	d'

I think the only problematic one is the first address, whose BRE
equivalent I think is

	/^`\{0,1\}[a-zA-Z].*\..*`\{0,1\}::$/

In practice, I suspect \{0,1\} is unnecessarily strict and using
something looser like

	/^`*[a-zA-Z].*\..*`*::$/

may be sufficient.  Replace the address expression associated with
the {editing command} and drop "-E", and use "-e" for readability,
perhaps?

Totally untested patch follows.

 GIT-VERSION-GEN        | 2 +-
 generate-configlist.sh | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git c/GIT-VERSION-GEN w/GIT-VERSION-GEN
index 208e91a17f..de989657fb 100755
--- c/GIT-VERSION-GEN
+++ w/GIT-VERSION-GEN
@@ -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|" \
diff --git c/generate-configlist.sh w/generate-configlist.sh
index 9d2ad6165d..75c39ade20 100755
--- c/generate-configlist.sh
+++ w/generate-configlist.sh
@@ -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,

```

## Brad Smith, 2025-06-12 04:13

Subject: Re: Solaris sed
Message-ID: <caaa5d54-d32d-40b3-9bf3-0f322e7c4316@comstyle.com>
URL: https://gitlist.dev/e/caaa5d54-d32d-40b3-9bf3-0f322e7c4316%40comstyle.com
In-Reply-To: <xmqqo6utfvxu.fsf@gitster.g>

```
On 2025-06-12 12:03 a.m., Junio C Hamano wrote:
> Brad Smith <brad@comstyle.com> writes:
>
>> Building on Solaris I noticed the following two issues with Solaris sed.
>>
>>      GEN version-def.h
>> sed: Missing newline at end of file standard input.
> Perhaps it is this input line it is complaining about.  sed works on
> text files, and a file that ends in incomplete line was not quite
> text.
>
> -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|" \
>
>>      GEN config-list.h
>> sed: illegal option -- E
>> Usage:  sed [-n] script [file...]
>>          sed [-n] [-e script]...[-f script_file]...[file...]
> This is a bit trickier but should be doable.  It does not like the
> -E option to use ERE (as opposed to BRE) for pattern matching used
> in generate-configlist.sh script.
>
> 	sed -E '
> 	/^`?[a-zA-Z].*\..*`?::$/ {
> 	/deprecated/d;
> 	s/::$//;
> 	s/`//g;
> 	s/^.*$/	"&",/;
> 	p;};
> 	d'
>
> I think the only problematic one is the first address, whose BRE
> equivalent I think is
>
> 	/^`\{0,1\}[a-zA-Z].*\..*`\{0,1\}::$/
>
> In practice, I suspect \{0,1\} is unnecessarily strict and using
> something looser like
>
> 	/^`*[a-zA-Z].*\..*`*::$/
>
> may be sufficient.  Replace the address expression associated with
> the {editing command} and drop "-E", and use "-e" for readability,
> perhaps?
>
> Totally untested patch follows.
>
>   GIT-VERSION-GEN        | 2 +-
>   generate-configlist.sh | 8 ++++----
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git c/GIT-VERSION-GEN w/GIT-VERSION-GEN
> index 208e91a17f..de989657fb 100755
> --- c/GIT-VERSION-GEN
> +++ w/GIT-VERSION-GEN
> @@ -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|" \
> diff --git c/generate-configlist.sh w/generate-configlist.sh
> index 9d2ad6165d..75c39ade20 100755
> --- c/generate-configlist.sh
> +++ w/generate-configlist.sh
> @@ -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,


No errors or warnings after this is applied.


```

## Eli Schwartz, 2025-06-12 04:16

Subject: Re: Solaris sed
Message-ID: <ed3d9c32-5de8-4653-be75-d2b5c89340e0@gentoo.org>
URL: https://gitlist.dev/e/ed3d9c32-5de8-4653-be75-d2b5c89340e0%40gentoo.org
In-Reply-To: <f2082cde-7eb9-4927-a01c-e6fb3b355d13@comstyle.com>

```
On 6/11/25 11:49 PM, Brad Smith wrote:
> On 2025-06-11 11:42 p.m., Collin Funk wrote:
>> Hi Brad,
>>
>> Brad Smith <brad@comstyle.com> writes:
>>
>>> Building on Solaris I noticed the following two issues with Solaris sed.
>>>
>>>      GEN version-def.h
>>> sed: Missing newline at end of file standard input.
>>>
>>>      GEN config-list.h
>>> sed: illegal option -- E
>>> Usage:  sed [-n] script [file...]
>>>          sed [-n] [-e script]...[-f script_file]...[file...]
>>>
>>>
>>> https://github.com/git/git/commit/
>>> e1b81f54da80267edee2cb8fd0d0f75f03023019
>>>
>>> The second issue being introduced fairly recently. Not sure what
>>> would be
>>> appropriate fixes. Just pointing them out if someone has an
>>> suggestions for
>>> fixes.
>> I noticed these as well, but just ignored them since it seems to build
>> fine.
>>
>> The first one seems like just a warning? Probably something to do with
>> POSIX defining a "Text File" as "A file that contains characters
>> organized into zero or more lines" where a line is "A sequence of zero
>> or more non- <newline> characters plus a terminating <newline>
>> character."
> It looks as if it is just a warning to me. I wasn't worrying about that
> one as much
> as I was the second issue.
>> The second is more tricky. The '-E' option to use EREs was not added to
>> the specification for 'sed' until POSIX.1-2024 [1]. Maybe the script
>> could check for the 'gsed' command? All of the (few) Solaris machines I
>> use will have many GNU programs installed like that.
> I can't comment on that especially as the build bits support pretty old
> releases and
> I have no idea how long Sun / Oracle have been shipping GNU bits like
> this. I do not
> believe this has always been a thing.


The Solaris box I have a shell on, has gsed installed as a purely
optional third-party addon from a third-party package feed. As far as I
know, Solaris never did nor plans to ship "GNU bits like this".

Of course, the Git project *could* declare users must first build GNU
sed, then build Git. Or only build on boxes where the admin is a GNU
enthusiast. But that option seems unlikely and unattractive...


-- 
Eli Schwartz

```

## Collin Funk, 2025-06-12 04:19

Subject: Re: Solaris sed
Message-ID: <874iwlegmg.fsf@gmail.com>
URL: https://gitlist.dev/e/874iwlegmg.fsf%40gmail.com
In-Reply-To: <caaa5d54-d32d-40b3-9bf3-0f322e7c4316@comstyle.com>

```
Brad Smith <brad@comstyle.com> writes:

>> Totally untested patch follows.
>>
>>   GIT-VERSION-GEN        | 2 +-
>>   generate-configlist.sh | 8 ++++----
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git c/GIT-VERSION-GEN w/GIT-VERSION-GEN
>> index 208e91a17f..de989657fb 100755
>> --- c/GIT-VERSION-GEN
>> +++ w/GIT-VERSION-GEN
>> @@ -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|" \
>> diff --git c/generate-configlist.sh w/generate-configlist.sh
>> index 9d2ad6165d..75c39ade20 100755
>> --- c/generate-configlist.sh
>> +++ w/generate-configlist.sh
>> @@ -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,
>
>
> No errors or warnings after this is applied.

Likewise.

I checked on my Linux machine and both files are the same before and
after the patch. Before the patch on Solaris 10, the following is
generated:

    /* Automatically generated by generate-configlist.sh */
    
    
    static const char *config_name_list[] = {
            NULL,
    };

After the patch the output on Solaris is the same as on Linux.

So the patch is perfect.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Collin

```

## Collin Funk, 2025-06-12 04:25

Subject: Re: Solaris sed
Message-ID: <87v7p1d1rf.fsf@gmail.com>
URL: https://gitlist.dev/e/87v7p1d1rf.fsf%40gmail.com
In-Reply-To: <ed3d9c32-5de8-4653-be75-d2b5c89340e0@gentoo.org>

```
Eli Schwartz <eschwartz@gentoo.org> writes:

>>> The second is more tricky. The '-E' option to use EREs was not added to
>>> the specification for 'sed' until POSIX.1-2024 [1]. Maybe the script
>>> could check for the 'gsed' command? All of the (few) Solaris machines I
>>> use will have many GNU programs installed like that.
>> I can't comment on that especially as the build bits support pretty old
>> releases and
>> I have no idea how long Sun / Oracle have been shipping GNU bits like
>> this. I do not
>> believe this has always been a thing.
>
>
> The Solaris box I have a shell on, has gsed installed as a purely
> optional third-party addon from a third-party package feed. As far as I
> know, Solaris never did nor plans to ship "GNU bits like this".

Yes, sorry for not being clear. It is not installed by default. On the
compile farm machines I have access to it is always installed by the
maintainer. Or on VMs I use, I always download it. I figured that is
pretty common.

> Of course, the Git project *could* declare users must first build GNU
> sed, then build Git. Or only build on boxes where the admin is a GNU
> enthusiast. But that option seems unlikely and unattractive...

Perhaps I am too mean to Solaris... Their 'date' command made me give a
similar recommendation before. Anyways, Junio wrote a patch that avoids
us forcing GNU tools on them.

Collin

```

## Brad Smith, 2025-06-12 04:26

Subject: Re: Solaris sed
Message-ID: <e63d1ef3-6bd9-4720-95ea-16c800f549c1@comstyle.com>
URL: https://gitlist.dev/e/e63d1ef3-6bd9-4720-95ea-16c800f549c1%40comstyle.com
In-Reply-To: <ed3d9c32-5de8-4653-be75-d2b5c89340e0@gentoo.org>

```
On 2025-06-12 12:16 a.m., Eli Schwartz wrote:
> On 6/11/25 11:49 PM, Brad Smith wrote:
>> On 2025-06-11 11:42 p.m., Collin Funk wrote:
>>> Hi Brad,
>>>
>>> Brad Smith <brad@comstyle.com> writes:
>>>
>>>> Building on Solaris I noticed the following two issues with Solaris sed.
>>>>
>>>>       GEN version-def.h
>>>> sed: Missing newline at end of file standard input.
>>>>
>>>>       GEN config-list.h
>>>> sed: illegal option -- E
>>>> Usage:  sed [-n] script [file...]
>>>>           sed [-n] [-e script]...[-f script_file]...[file...]
>>>>
>>>>
>>>> https://github.com/git/git/commit/
>>>> e1b81f54da80267edee2cb8fd0d0f75f03023019
>>>>
>>>> The second issue being introduced fairly recently. Not sure what
>>>> would be
>>>> appropriate fixes. Just pointing them out if someone has an
>>>> suggestions for
>>>> fixes.
>>> I noticed these as well, but just ignored them since it seems to build
>>> fine.
>>>
>>> The first one seems like just a warning? Probably something to do with
>>> POSIX defining a "Text File" as "A file that contains characters
>>> organized into zero or more lines" where a line is "A sequence of zero
>>> or more non- <newline> characters plus a terminating <newline>
>>> character."
>> It looks as if it is just a warning to me. I wasn't worrying about that
>> one as much
>> as I was the second issue.
>>> The second is more tricky. The '-E' option to use EREs was not added to
>>> the specification for 'sed' until POSIX.1-2024 [1]. Maybe the script
>>> could check for the 'gsed' command? All of the (few) Solaris machines I
>>> use will have many GNU programs installed like that.
>> I can't comment on that especially as the build bits support pretty old
>> releases and
>> I have no idea how long Sun / Oracle have been shipping GNU bits like
>> this. I do not
>> believe this has always been a thing.
>
> The Solaris box I have a shell on, has gsed installed as a purely
> optional third-party addon from a third-party package feed. As far as I
> know, Solaris never did nor plans to ship "GNU bits like this".
>
> Of course, the Git project *could* declare users must first build GNU
> sed, then build Git. Or only build on boxes where the admin is a GNU
> enthusiast. But that option seems unlikely and unattractive...

To clarify what I meant. Solaris 11 from the looks of it includes GNU 
sed with
the base OS. That was not the case with 10 and older.

The documentation for 11.4 for example mentions both versions of sed.

https://docs.oracle.com/cd/E88353_01/html/E37839/sed-1.html
https://docs.oracle.com/cd/E88353_01/html/E37839/sed-1g.html

```

## Eric Sunshine, 2025-06-12 05:50

Subject: Re: Solaris sed
Message-ID: <CAPig+cROcMt1crKjvqcetFNGdE4ywmD1+NO+q+MnDzctx8ewag@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcROcMt1crKjvqcetFNGdE4ywmD1%2BNO%2Bq%2BMnDzctx8ewag%40mail.gmail.com
In-Reply-To: <xmqqo6utfvxu.fsf@gitster.g>

```
On Thu, Jun 12, 2025 at 12:05 AM Junio C Hamano <gitster@pobox.com> wrote:
> Brad Smith <brad@comstyle.com> writes:
> > Building on Solaris I noticed the following two issues with Solaris sed.
> >     GEN version-def.h
> > sed: Missing newline at end of file standard input.
>
> Perhaps it is this input line it is complaining about.  sed works on
> text files, and a file that ends in incomplete line was not quite
> text.
>
> -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|" \

It's curious that this is using:

    printf "%s" "$foo"`

in the first place. Had it used the simpler:

    echo "$foo"

this sort of problem (forgetting the "\n") would never have occurred.

In fact, it seems that f6a2efdc9b (GIT-VERSION-GEN: allow running
without input and output files, 2025-01-22), which introduced this
problem, also introduced a few similar cases in which the `printf
"%s\n"` idiom was employed when a simple `echo` would have sufficed.

```

## Paul Smith, 2025-06-12 13:35

Subject: Re: Solaris sed
Message-ID: <b2d23be73902c8433295e2a5f30b051d044e227c.camel@mad-scientist.net>
URL: https://gitlist.dev/e/b2d23be73902c8433295e2a5f30b051d044e227c.camel%40mad-scientist.net
In-Reply-To: <CAPig+cROcMt1crKjvqcetFNGdE4ywmD1+NO+q+MnDzctx8ewag@mail.gmail.com>

```
On Thu, 2025-06-12 at 01:50 -0400, Eric Sunshine wrote:
> Had it used the simpler:
> 
>     echo "$foo"
> 
> this sort of problem (forgetting the "\n") would never have occurred.

Just be aware that echo is not well-standardized: many versions of echo
accept extra options or treat certain chars specially.  So, printf
(which IS well-standardized) is always safer unless you are 100% sure
that the text on the echo command line is simple: cannot start with a
"-", doesn't contain special chars like backslash, etc.

For portability I (personally) always prefer printf unless I know
exactly what the text contains (like showing a static string).

```

## Eric Sunshine, 2025-06-12 16:40

Subject: Re: Solaris sed
Message-ID: <CAPig+cREA6YdMgbZ59eGnU8SRWmfNR8bGGvLfTQEpS4PqKm9mg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcREA6YdMgbZ59eGnU8SRWmfNR8bGGvLfTQEpS4PqKm9mg%40mail.gmail.com
In-Reply-To: <b2d23be73902c8433295e2a5f30b051d044e227c.camel@mad-scientist.net>

```
On Thu, Jun 12, 2025 at 9:44 AM Paul Smith <paul@mad-scientist.net> wrote:
> On Thu, 2025-06-12 at 01:50 -0400, Eric Sunshine wrote:
> > Had it used the simpler:
> >
> >     echo "$foo"
> >
> > this sort of problem (forgetting the "\n") would never have occurred.
>
> Just be aware that echo is not well-standardized: many versions of echo
> accept extra options or treat certain chars specially.  So, printf
> (which IS well-standardized) is always safer unless you are 100% sure
> that the text on the echo command line is simple: cannot start with a
> "-", doesn't contain special chars like backslash, etc.
>
> For portability I (personally) always prefer printf unless I know
> exactly what the text contains (like showing a static string).

Yup, you're right. I always do the same when I can't trust the
argument to be `echo`-safe, but apparently I wasn't thinking of that
case when I wrote the email. Thanks for the dose of sanity.

```

## Jean-Noël AVILA, 2025-06-13 20:13

Subject: Re: Solaris sed
Message-ID: <5895400.DvuYhMxLoT@cayenne>
URL: https://gitlist.dev/e/5895400.DvuYhMxLoT%40cayenne
In-Reply-To: <874iwlegmg.fsf@gmail.com>

```
On Thursday, 12 June 2025 06:19:35 CEST Collin Funk wrote:
> Brad Smith <brad@comstyle.com> writes:

> > No errors or warnings after this is applied.
> 
> Likewise.
> 
> I checked on my Linux machine and both files are the same before and
> after the patch. Before the patch on Solaris 10, the following is
> generated:
> 
>     /* Automatically generated by generate-configlist.sh */
> 
> 
>     static const char *config_name_list[] = {
>             NULL,
>     };
> 
> After the patch the output on Solaris is the same as on Linux.
> 
> So the patch is perfect.
> 
> Reviewed-by: Collin Funk <collin.funk1@gmail.com>
> 
> Collin

Hello, 

Would it be possible to set up some kind of CI to check for compatibility with 
such systems. This is the second time I introduced regressions without even 
knowing it, and it would be really great to catch them before borking a 
release process.

Thanks,

JN




```

## Eric Sunshine, 2025-06-13 20:23

Subject: Re: Solaris sed
Message-ID: <CAPig+cSu7+fxveULiB1vDbcy6Cnia_5isVVy+RCO+HGAyr8uvg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcSu7%2BfxveULiB1vDbcy6Cnia_5isVVy%2BRCO%2BHGAyr8uvg%40mail.gmail.com
In-Reply-To: <5895400.DvuYhMxLoT@cayenne>

```
On Fri, Jun 13, 2025 at 4:15 PM Jean-Noël AVILA <jn.avila@free.fr> wrote:
> Would it be possible to set up some kind of CI to check for compatibility with
> such systems. This is the second time I introduced regressions without even
> knowing it, and it would be really great to catch them before borking a
> release process.

Had this been in a test script, it would have been caught by
t/check-non-portable-shell.sh. We may want to apply the check to
build-related scripts, as well. For instance, it would have caught the
-E problem:

    % ./t/check-non-portable-shell.pl generate-*.sh
    generate-configlist.sh:16: error: sed option not portable (use
only -n, -e, -f): sed -E '
    %

You can, of course, run check-non-portable-shell.pl manually after
editing a script, but perhaps this check could be enabled by a
(hopefully) minor tweak to the main Git Makefile?

```

## Collin Funk, 2025-06-13 20:30

Subject: Re: Solaris sed
Message-ID: <87ikkzs7su.fsf@gmail.com>
URL: https://gitlist.dev/e/87ikkzs7su.fsf%40gmail.com
In-Reply-To: <5895400.DvuYhMxLoT@cayenne>

```
Jean-Noël AVILA <jn.avila@free.fr> writes:

> Would it be possible to set up some kind of CI to check for compatibility with 
> such systems. This is the second time I introduced regressions without even 
> knowing it, and it would be really great to catch them before borking a 
> release process.

I'm sure that Solaris packagers are used to patching stuff like this. I
wouldn't feel guilty about it. It is difficult to remember all these
portability quirks.

With GitHub actions you can add Oracle Solaris and OmniOS (based on
illumos, which was based on OpenSolaris) using vmactions [1]. That might
help catch some stuff.

In this case, the build still works even with the broken sed commands.
Not sure if the tests would have caught it though.

Collin

[1] https://github.com/vmactions

```
