RFR: 8301197: Make sure use of printf is correct and actually needed

Erik Joelsson erikj at openjdk.org
Fri Apr 4 13:57:12 UTC 2025


On Fri, 4 Apr 2025 13:41:17 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

>> I wasn't aware of that feature in `echo`, but I agree that if we are using printf just to omit the line break, then `echo -n` seems like a better choice.
>
> I'm not sure I agree. Why would:
> 
> $$(ECHO) -n '$$($1_OVERVIEW_TEXT)' 
> 
> be better than
> 
> $$(PRINTF) "%s" '$$($1_OVERVIEW_TEXT)' 
> 
> ?
> 
> We're kind of squabbling over details here, and it really doesn't matter as much, but I don't think there is really anything to gain by going down that route. If nothing else, `echo -n` seems like less widespread knowledge (Erik didn't know, I knew but had forgot since I never use it). In contrast, I believe the printf syntax is a bit more well known.
> 
> But sure, I can use `echo -n` instead of `printf` where possible. Just give me one good reason why.

I just thought that if you tried to standardized on `echo` where possible instead of `printf`, it would make sense. I often feel awkward having to switch to the completely different syntax of printf just to prevent the newline. Having a simple option to echo that just omits the newline seems more straightforward. There are of course still usecases for printf. I don't mind that much either way though, so I'm really fine with either.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24415#discussion_r2028859754


More information about the build-dev mailing list