use child_process member "args" instead of string array variable
Use run_command() with a struct child_process variable and populate its "args" member directly instead of building a string array and passing it to run_command_v_opt(). This avoids the use of magic index numbers and makes simplifies the possible addition of more arguments in the future. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:

committed by
Taylor Blau

parent
242aa33de0
commit
4120294cbf
@ -193,7 +193,7 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
|
||||
struct strbuf cmd = STRBUF_INIT;
|
||||
struct strbuf_expand_dict_entry dict[6];
|
||||
struct strbuf path_sq = STRBUF_INIT;
|
||||
const char *args[] = { NULL, NULL };
|
||||
struct child_process child = CHILD_PROCESS_INIT;
|
||||
int status, fd, i;
|
||||
struct stat st;
|
||||
enum ll_merge_result ret;
|
||||
@ -219,8 +219,9 @@ static enum ll_merge_result ll_ext_merge(const struct ll_merge_driver *fn,
|
||||
|
||||
strbuf_expand(&cmd, fn->cmdline, strbuf_expand_dict_cb, &dict);
|
||||
|
||||
args[0] = cmd.buf;
|
||||
status = run_command_v_opt(args, RUN_USING_SHELL);
|
||||
child.use_shell = 1;
|
||||
strvec_push(&child.args, cmd.buf);
|
||||
status = run_command(&child);
|
||||
fd = open(temp[1], O_RDONLY);
|
||||
if (fd < 0)
|
||||
goto bad;
|
||||
|
Reference in New Issue
Block a user