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

Re: [PATCH] t5702: be more resilient to env quoting

From
Jeff King <peff@peff.net>
Date
Nov 4, 2026, 06:32 UTC
Message-ID
<20261104063201.GA1543013@coredump.intra.peff.net>
In-Reply-To
<87jymy5uek.fsf@gmail.com>
On Fri, Oct 30, 2026 at 10:08:35PM -0700, Collin Funk wrote:
Show 10 quoted lines
> Nice catch on the NEWS entry. Sorry to you both for the extra work. I am
> at least partly to blame for those changes.
> 
> In coreutils-9.12, we made 'env' and 'printenv' quote their output. This
> was to make the output more robust in the case of whitespace, special
> characters, and in particular, newlines in environment variables.
> Specifically, any program that parses the output of 'env', without -0,
> will certainly mistake environment variables with newlines in them as
> multiple environment variables. See the following example of the output
> before coreutils-9.12:

Though it created some extra work here, I think this is a good change. There's another spot where we use "env" in the test suite that I was looking at a month or two ago, and I was mildly terrified that it would allow variable injection (though probably not a big deal in practice for our purposes). So I'm happy to see the situation improving.

> In all of the cases that I have seen where the 9.12 behavior caused
> problems, quoting only when standard output is a terminal would have
> avoided all of them.
Yeah, but then we lose the injection protection. :)
What a complicated world we live in.
> Note that some distributions may have also picked up the patch adding
> the --quoting-style option [6] (I think Slackware did, not sure if
> anyone else did). But that hasn't been in a release yet, so you probably
> don't want to use it.

Yeah, I don't have it here yet. I do agree it's good to have, as it lets the caller be careful when they know they're going to eval the result. Though of course it creates its own headaches, because we might not be using coreutils env. :-/

> Sorry again for the extra work of having to investigate that behavior
> change.

No worries, and thanks for the explanation. I think the revised code in git.git is better for not using "env" anyway.

-Peff
Previous: Collin FunkNext: Collin Funk
Message 5 of 9 in “t5702: be more resilient to env quoting”
  1. t5702: be more resilient to env quotingJeff King, Oct 31, 2026
  2. Todd ZullingerOct 31, 2026
  3. Jeff KingOct 31, 2026
  4. Collin FunkOct 31, 2026
  5. Jeff KingNov 4, 2026
  6. Collin FunkOct 31, 2026
  7. Junio C HamanoOct 31, 2026
  8. Jeff KingOct 31, 2026
  9. Junio C HamanoNov 1, 2026

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.