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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jan Hudec
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 <[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[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 <[hidden email]>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

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

Junio C Hamano
Jan Hudec <[hidden email]> writes:

> On UNIX, not only that argv[0] 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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html