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

Re: [PATCH] t/t9902-completion.sh: backslashes in echo

From
Marcel Telka <marcel@telka.sk>
Date
May 23, 2024, 21:47 UTC
Message-ID
<Zk-5YCKSO32vPKDP@telcontar>
In-Reply-To
<CAPig+cRddr=JTVvkh5xkptag_1C5-z1t9Pzr_OdcGFSVwRg3vg@mail.gmail.com>
On Thu, May 23, 2024 at 05:06:00PM -0400, Eric Sunshine wrote:
Show 26 quoted lines
> On Thu, May 23, 2024 at 4:32 PM Marcel Telka <marcel@telka.sk> wrote:
> > On Thu, May 23, 2024 at 10:59:13AM -0700, Junio C Hamano wrote:
> > > Marcel Telka <marcel@telka.sk> writes:
> > > > The usage of backslashes in echo is not portable.  Since some tests
> > > > tries to output strings containing '\b' it is safer to use printf
> > > > here.  The usage of printf instead of echo is also preferred by POSIX.
> > >
> > > This has cooked in 'next' for some time already, and I'll merge this
> > > down to 'master' anyway, but this being a script very much speicific
> > > to bash whose built-in echo we are using, the portability argument
> > > of "echo" made in the proposed log message does not quite apply to
> > > this patch.
> >
> > Could you please help me to understand how the bash is used to run the
> > script?
> >
> > $ head -n 1 t/t9902-completion.sh
> > #!/bin/sh
> 
> Looking a bit farther in t9902, you'll find:
> 
>     . ./lib-bash.sh
> 
> And if you look inside `lib-bash.sh`, you'll see that, if the
> currently-running shell is not Bash, it aborts the current script and
> re-runs it under Bash.
Thanks for the pointer!

Interesting. I came to this issue because the test failed here due to the echo. So apparently the re-run under bash didn't happen here for some reason or bash's echo behaved differently? I need to dig into it again to find what's going on.

Show 5 quoted lines
> But Junio's point was that t9902 is dedicated to testing Bash-specific
> functionality, so the commit message's justification to avoid this
> non-POSIX behavior isn't necessarily a good justification for the
> change. (He wasn't saying that the change itself was unwelcome, just
> that the commit message wasn't convincing.)

Sure. I understand the point. I just had an impression that the test is running under POSIX sh (/bin/sh), not bash, because it failed here (see above).

OTOH, it seems that the fix is maybe not needed because it is solving a non-problem.

Thank you.
-- 
+-------------------------------------------+
| Marcel Telka   e-mail:   marcel@telka.sk  |
|                homepage: http://telka.sk/ |
+-------------------------------------------+
Previous: Eric SunshineNext: Marcel Telka
Message 5 of 10 in “t/t9902-completion.sh: backslashes in echo”
  1. t/t9902-completion.sh: backslashes in echoMarcel Telka, May 17, 2024
  2. Junio C HamanoMay 23, 2024
  3. Marcel TelkaMay 23, 2024
  4. Eric SunshineMay 23, 2024
  5. Marcel TelkaMay 23, 2024
  6. Marcel TelkaMay 23, 2024
  7. Marcel TelkaMay 23, 2024
  8. Junio C HamanoMay 23, 2024
  9. Eric SunshineMay 23, 2024
  10. Marcel TelkaMay 23, 2024

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.