git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Solaris sed

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jun 12, 2025, 05:50 UTC
Message-ID
<CAPig+cROcMt1crKjvqcetFNGdE4ywmD1+NO+q+MnDzctx8ewag@mail.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:
Show 14 quoted lines
> 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.

Previous: Collin FunkNext: Paul Smith
Message 13 of 15 in “Solaris sed”
  1. Brad SmithJun 12, 2025
  2. Collin FunkJun 12, 2025
  3. Brad SmithJun 12, 2025
  4. Eli SchwartzJun 12, 2025
  5. Collin FunkJun 12, 2025
  6. Brad SmithJun 12, 2025
  7. Junio C HamanoJun 12, 2025
  8. Brad SmithJun 12, 2025
  9. Collin FunkJun 12, 2025
  10. Jean-Noël AVILAJun 13, 2025
  11. Eric SunshineJun 13, 2025
  12. Collin FunkJun 13, 2025
  13. Eric SunshineJun 12, 2025
  14. Paul SmithJun 12, 2025
  15. Eric SunshineJun 12, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.