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

Re: [PATCH] Set up argv0_path correctly, even when argv[0] is just the basename

From
JHJan Hudec <bulb@ucw.cz>
Date
Aug 3, 2008, 20:25 UTC
Message-ID
<20080803202513.GC3482@efreet.light.src>
In-Reply-To
<alpine.DEB.1.00.0807261613120.26810@eeepc-johanness>
On Sat, Jul 26, 2008 at 16:14:33 +0200, Johannes Schindelin wrote:
Show 13 quoted lines
> When the program 'git' is in the PATH, the argv[0] is set to the basename.
> However, argv0_path needs the full path, so add a function to discover the
> program by traversing the PATH manually.
> 
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> 
> 	So it is not easily possible to reuse this function in 
> 	compat/mingw.c, as Junio said that compat/ should not depend
> 	(at least too much) on libgit.a.
> 
> 	Of course, we could try to follow a symlinked git, too, but I 
> 	think this is overkill until someone proves me wrong.

On UNIX, not only that argv[0] can contain the program without path -- it can contain anything the user thinks of. However most systems provide some way to get the path of the executable. On Linux (and some other unices, but not all of them) a reliable way is to readlink("/proc/self/exe", ...). Maybe since it's only needed for resolving a relative exec dir, relative exec dir could be supported only on systems that have such method (which is most of them).

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Johannes SchindelinNext: Junio C Hamano
Message 12 of 21 in “Modify mingw_main() workaround to avoid link errors”
  1. Modify mingw_main() workaround to avoid link errorsSteffen Prohaska, Jul 26, 2008
  2. Johannes SchindelinJul 26, 2008
  3. Steffen ProhaskaJul 26, 2008
  4. Set up argv0_path correctly, even when argv[0] is just the basenameJohannes Schindelin, Jul 26, 2008
  5. Rene HermanJul 26, 2008
  6. Johannes SchindelinJul 26, 2008
  7. Rene HermanJul 26, 2008
  8. Johannes SchindelinJul 26, 2008
  9. Rene HermanJul 26, 2008
  10. Junio C HamanoJul 26, 2008
  11. Johannes SchindelinJul 26, 2008
  12. Jan HudecAug 3, 2008
  13. Junio C HamanoAug 3, 2008
  14. Johannes SixtJul 26, 2008
  15. Steffen ProhaskaJul 26, 2008
  16. Johannes SixtJul 27, 2008
  17. Steffen ProhaskaJul 29, 2008
  18. Johannes SixtJul 29, 2008
  19. Steffen ProhaskaJul 29, 2008
  20. Johannes SixtAug 3, 2008
  21. Junio C HamanoAug 3, 2008

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.