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

Re: [PATCH] t0300: workaround bug in FreeBSD < 10 sh

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
May 14, 2020, 23:30 UTC
Message-ID
<20200514233051.GB38566@Carlos-MBP>
In-Reply-To
<20200514220346.GA3074610@coredump.intra.peff.net>
On Thu, May 14, 2020 at 06:03:46PM -0400, Jeff King wrote:
Show 11 quoted lines
> On Thu, May 14, 2020 at 02:05:18PM -0700, Carlo Marcelo Arenas Belón wrote:
> 
> > 4c5971e18a (credential: treat "?" and "#" in URLs as end of host,
> > 2020-04-14) introduces check_host_and_path to t0300 and some tests that
> > use it, but fail in at least FreeBSD 9.3.
> > 
> > The variables in the here-doc fail to be expanded until they are used as
> > part of the eval in check(), resulting in (ex: url=fill) instead of what
> > was expected.
> 
> Wow, that's very surprising.

And luckily, also a problem that is no longer present with newer versions of the shell and neither NetBSD's or OpenBSD's AFAIK.

Show 17 quoted lines
> Just to be clear, if you run:
> 
> foo() {
>   for i in "$@"; do
>     echo "arg:$i"
>   done
>   sed s/^/stdin:/
> }
> set -- outer
> foo inner <<EOF
> $1
> EOF
> 
> do you get:
> 
> arg:inner
> stdin:inner

correct, so the problem was in the here-doc, not the eval; thanks for your explanation and reproduction, will update it in the reroll.

$ foo() {
Show 5 quoted lines
>   for i in "$@"; do
>     echo "arg:$i"
>   done
>   sed s/^/stdin:/
> }

$ set -- outer $ foo inner <<EOF

> $1
> EOF

arg:inner stdin:inner

> ? (on dash and bash, I get stdin:outer as expected). I don't think the
> fact that check() uses eval() should matter, because we'd be
> interpreting that here-doc earlier as part of read_chunk().

indeed, apologies for the extra quoting which was part of my original debugging and wasn't really needed.

will keep it without the inversion, only because I think it looks also clearer with the added indentantion.

Carlo
Previous: Eric SunshineNext: brian m. carlson
Message 4 of 7 in “t0300: workaround bug in FreeBSD < 10 sh”
  1. t0300: workaround bug in FreeBSD < 10 shCarlo Marcelo Arenas Belón, May 14, 2020
  2. Jeff KingMay 14, 2020
  3. Eric SunshineMay 14, 2020
  4. Carlo Marcelo Arenas BelónMay 14, 2020
  5. brian m. carlsonMay 14, 2020
  6. Junio C HamanoMay 14, 2020
  7. Carlo Marcelo Arenas BelónMay 14, 2020

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.