Erik Faye-Lund wrote: > --- a/git.c > +++ b/git.c > @@ -177,19 +177,20 @@ static int handle_alias(int *argcp, const char ***argv) [...] > - trace_printf("trace: alias to shell cmd: %s => %s\n", > - alias_command, alias_string + 1); Replaced by trace: run_command: ... (followed by "trace: exec: ..." on non-Windows (execv_shell_cmd)). Ok. > - ret = system(alias_string + 1); > + > + /* build alias_argv */ > + alias_argv = malloc(sizeof(char *) * *argcp + 1); This seems to be missing parentheses, so valgrind will complain except on 8-bit systems. ;-) What if malloc fails? > + alias_argv[0] = alias_string + 1; > + for (i = 1; i < *argcp; ++i) > + alias_argv[i] = (*argv)[i]; > + alias_argv[*argcp] = NULL; Nit: all these *argcp are noisy. > + > + ret = run_command_v_opt(alias_argv, RUN_USING_SHELL); > + > if (ret >= 0 && WIFEXITED(ret) && The return value from run_command and from system do not mean the same thing. > die("Failed to run '%s' when expanding alias '%s'", > alias_string + 1, alias_command); run_command already prints an error message, but this one still seems useful since it mentions the alias. Except as noted above, Reviewed-by: Jonathan Nieder <jrnieder@xxxxxxxxx> Thanks. diff --git a/git.c b/git.c index 5b0b9d8..dbf061d 100644 --- a/git.c +++ b/git.c @@ -178,22 +178,20 @@ static int handle_alias(int *argcp, const char ***argv) if (alias_string) { if (alias_string[0] == '!') { const char **alias_argv; - int i; + int argc = *argcp, i; commit_pager_choice(); - /* build alias_argv */ - alias_argv = malloc(sizeof(char *) * *argcp + 1); + alias_argv = xmalloc(sizeof(*alias_argv) * (argc + 1)); alias_argv[0] = alias_string + 1; - for (i = 1; i < *argcp; ++i) + for (i = 1; i < argc; ++i) alias_argv[i] = (*argv)[i]; - alias_argv[*argcp] = NULL; + alias_argv[argc] = NULL; ret = run_command_v_opt(alias_argv, RUN_USING_SHELL); + if (ret >= 0) /* normal exit */ + exit(ret); - if (ret >= 0 && WIFEXITED(ret) && - WEXITSTATUS(ret) != 127) - exit(WEXITSTATUS(ret)); die("Failed to run '%s' when expanding alias '%s'", alias_string + 1, alias_command); } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html