All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Scott Parish <sRp@srparish.net>, git@vger.kernel.org
Subject: Re: [PATCH] execv_git_cmd(): also try PATH if everything else fails.
Date: Sat, 20 Oct 2007 22:36:14 -0400	[thread overview]
Message-ID: <20071021023614.GB14735@spearce.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0710202258440.25221@racer.site>

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 	On Sat, 20 Oct 2007, Scott Parish wrote:
> 
> 	> Actually, i didn't test it right, execve() were using the files 
> 	> in my cwd. In addition to you patch, you'd need to use execvp() 
> 	> instead of execve().
> 
> 	Ah, right.  I missed that one ;-)
> 
> 	How about this instead?

Uhhh.  Its the same, isn't it?  Still using execve() which means
we will not look at PATH in the final attempt.
 
>  exec_cmd.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/exec_cmd.c b/exec_cmd.c
> index 9b74ed2..c928f37 100644
> --- a/exec_cmd.c
> +++ b/exec_cmd.c
> @@ -36,7 +36,8 @@ int execv_git_cmd(const char **argv)
>  	int i;
>  	const char *paths[] = { current_exec_path,
>  				getenv(EXEC_PATH_ENVIRONMENT),
> -				builtin_exec_path };
> +				builtin_exec_path,
> +				"" };
>  
>  	for (i = 0; i < ARRAY_SIZE(paths); ++i) {
>  		size_t len;
> @@ -44,9 +45,12 @@ int execv_git_cmd(const char **argv)
>  		const char *exec_dir = paths[i];
>  		const char *tmp;
>  
> -		if (!exec_dir || !*exec_dir) continue;
> +		if (!exec_dir) continue;
>  
> -		if (*exec_dir != '/') {
> +		if (!*exec_dir)
> +			/* try PATH */
> +			*git_command = '\0';
> +		else if (*exec_dir != '/') {
>  			if (!getcwd(git_command, sizeof(git_command))) {
>  				fprintf(stderr, "git: cannot determine "
>  					"current directory: %s\n",
> @@ -81,7 +85,7 @@ int execv_git_cmd(const char **argv)
>  
>  		len = strlen(git_command);
>  		rc = snprintf(git_command + len, sizeof(git_command) - len,
> -			      "/git-%s", argv[0]);
> +			      "%sgit-%s", *exec_dir ? "/" : "", argv[0]);
>  		if (rc < 0 || rc >= sizeof(git_command) - len) {
>  			fprintf(stderr,
>  				"git: command name given is too long.\n");
> -- 
> 1.5.3.4.1287.g8b31e

-- 
Shawn.

  reply	other threads:[~2007-10-21  2:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-20  8:12 [PATCH] When exec'ing sub-commands, fall back on execvp (thePATH) Scott R Parish
2007-10-20 20:25 ` Johannes Schindelin
2007-10-20 20:57 ` Scott Parish
2007-10-20 22:00   ` [PATCH] execv_git_cmd(): also try PATH if everything else fails Johannes Schindelin
2007-10-21  2:36     ` Shawn O. Pearce [this message]
2007-10-21 21:59       ` Johannes Schindelin
2007-10-22  4:21         ` Shawn O. Pearce
2007-10-22 10:35           ` Johannes Schindelin
2007-10-23  4:34             ` Shawn O. Pearce
2007-10-23 11:12               ` Johannes Schindelin
2007-10-22 14:36         ` Scott Parish
2007-10-22 15:19           ` Andreas Ericsson
2007-10-22 15:36             ` Johannes Sixt
2007-10-23 11:12               ` Andreas Ericsson
2007-10-23 15:29                 ` Johannes Sixt
2007-10-21 18:21     ` Scott Parish
2007-10-21 22:02       ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071021023614.GB14735@spearce.org \
    --to=spearce@spearce.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=sRp@srparish.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.