Re: [PATCH] Set up argv0_path correctly, even when argv is just the basename
On Sat, Jul 26, 2008 at 16:14:33 +0200, Johannes Schindelin wrote:
> When the program 'git' is in the PATH, the argv 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 <[hidden email]>
> 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 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).
> On UNIX, not only that argv can contain the program without path -- it can
> contain anything the user thinks of.... 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).
The "relocatable install" itself is not usually a common concept in the
UNIX world, and I do not think this matters anyway.