Re: [PATCH] Set up argv0_path correctly, even when argv[0] is just the basename
From: Jan Hudec <hidden>
Date: 2016-06-15 22:45:06
On Sat, Jul 26, 2008 at 16:14:33 +0200, Johannes Schindelin wrote:
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 <redacted> --- 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 [off-list ref]