Re: [PATCH 1/6] run-command: add "use shell" option
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Jan 1, 2010, 22:12 UTC
- Message-ID
- <4B3E7354.209@kdbg.org>
- In-Reply-To
- <20091230105316.GA22959@coredump.intra.peff.net>
Jeff King schrieb:
Show 23 quoted lines
> Many callsites run "sh -c $CMD" to run $CMD. We can make it > a little simpler for them by factoring out the munging of > argv. > > For simple cases with no arguments, this doesn't help much, but: > > 1. For cases with arguments, we save the caller from > having to build the appropriate shell snippet. > > 2. We can later optimize to avoid the shell when > there are no metacharacters in the program. > > Signed-off-by: Jeff King <peff@peff.net> > --- > I made the matching tweak to the Windows half of run-command, but I > don't actually have a box to test it on. > > I modeled this after execv_git_cmd. Like that function, I try to release > the allocated argv on error. However, we do actually leak the strbuf > memory in one case. I'm not sure how much we care. On unix, this will > always happen in a forked process which will either exec or die. On > Windows, we seem to already be leaking the prepared argv for the git_cmd > case (and now we leak the shell_cmd case, too).
That is OK. We can fix this when we find a work-load where this is a problem.
But would you please squash this in to avoid a warning about an unused static function on Windows.
--- run-command.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/run-command.c b/run-command.c index 22e2777..47ced57 100644 --- a/run-command.c +++ b/run-command.c @@ -48,6 +48,7 @@ static const char **prepare_shell_cmd(const char **argv) return nargv; } +#ifndef WIN32 static int execv_shell_cmd(const char **argv) { const char **nargv = prepare_shell_cmd(argv); @@ -56,6 +57,7 @@ static int execv_shell_cmd(const char **argv) free(nargv); return -1; } +#endif int start_command(struct child_process *cmd) {
-- 1.6.6.1073.gd853b.dirty