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

Re: bug? subprocesses can use wrong Git if $PATH is unset

From
PRPriedhorsky, Reid <reidpr@lanl.gov>
Date
Jun 2, 2023, 16:14 UTC
Message-ID
<412E82B5-79C0-4AAD-8219-AA7664E9EE1E@lanl.gov>
In-Reply-To
<ZHk5V6U9gfkuwErH@tapette.crustytoothpaste.net>
Hello Brian,
Show 8 quoted lines
> On Jun 1, 2023, at 6:35 PM, brian m. carlson <sandals@crustytoothpaste.net> wrote:
> 
> It isn't possibly to portably determine that path that was used to exec
> the current binary, so Git doesn't try to do so, and it assumes that you
> set PATH appropriately.  In fact, on some systems, you can use fexecve
> to execute file descriptors pointing to files that have been unlinked,
> so in general, it's not possible to determine which binary to use
> without the PATH.
Thank you for the explanation. This is fascinating. It also explains why my script works as expected if I substitute “/usr/local/bin/git” for plain “git”.
> I don't think there's anything to change here in Git.
That seems convincing.
I do wonder if the behavior would be worth documenting, e.g. at https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables, where Git’s relationship to $HOME is also documented. I would be happy to submit a pull request.

Thanks, Reid

— he/his

Previous: brian m. carlsonNext: brian m. carlson
Message 3 of 6 in “bug? subprocesses can use wrong Git if $PATH is unset”
  1. Priedhorsky, ReidJun 1, 2023
  2. brian m. carlsonJun 2, 2023
  3. Priedhorsky, ReidJun 2, 2023
  4. brian m. carlsonJun 2, 2023
  5. Junio C HamanoJun 3, 2023
  6. Priedhorsky, ReidJun 7, 2023

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.