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

Re: [RFC PATCH 0/3] git-p4: move to toplevel

From
Jeff King <peff@peff.net>
Date
Feb 14, 2012, 19:05 UTC
Message-ID
<20120214190515.GB12072@sigill.intra.peff.net>
In-Reply-To
<7vaa4l8diz.fsf@alter.siamese.dyndns.org>
On Tue, Feb 14, 2012 at 10:40:04AM -0800, Junio C Hamano wrote:
> I do not think tilde in $PATH is expanded by exec*p family to begin with,
> so it is not "dash" but POSIX, I would think.  It is bash that is harming
> other programs, by trying to be more helpful, encouraging this user
> mistake to add ~ literally on the PATH.

Hmm. There is an interesting ramification for run-command's "use_shell" optimization. Typically, git runs all of the user-provided commands given to it via the shell. But if the command contains no meta-characters, we skip the shell invocation as an optimization, since the shell should simply be word-splitting and calling exec, and the behavior will be identical.

But if your shell handles PATH entries differently, then there is a difference. I.e., doing this:

  mkdir junk
  ln -s /usr/bin/vi junk/my-editor
  export PATH=~/junk:$PATH
  export GIT_EDITOR=my-editor
  git commit
might work without the optimization, but not with.

We could check PATH and disable the optimization in that case, but I suspect it is not worth it, as:

  1. People who put a literal "~" in their PATH get what they deserve
     anyway. :)
  2. We explicitly run "sh" in such situations, not SHELL_PATH. Even if
     "sh" is bash, I believe it should look at its own argv[0] and put
     itself into a more POSIX-y mode (but I didn't test).
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 16 in “git-p4: move to toplevel”
  1. 0/3 git-p4: move to toplevelPete Wyckoff, Feb 12, 2012
  2. 1/3 git-p4: move to toplevelPete Wyckoff, Feb 12, 2012
  3. 2/3 git p4: update name in scriptPete Wyckoff, Feb 12, 2012
  4. 3/3 git p4: use "git p4" directly in testsPete Wyckoff, Feb 12, 2012
  5. Luke DiamandFeb 12, 2012
  6. Junio C HamanoFeb 13, 2012
  7. Pete WyckoffFeb 13, 2012
  8. Junio C HamanoFeb 13, 2012
  9. Clemens BuchacherFeb 13, 2012
  10. Junio C HamanoFeb 13, 2012
  11. Pete WyckoffFeb 13, 2012
  12. Clemens BuchacherFeb 14, 2012
  13. Junio C HamanoFeb 14, 2012
  14. Jeff KingFeb 14, 2012
  15. Junio C HamanoFeb 14, 2012
  16. Clemens BuchacherFeb 14, 2012

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.