Re: [PATCH v2] alias: use run_command api to execute aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Donnerstag, 6. Januar 2011, Erik Faye-Lund wrote:
> @@ -177,22 +177,22 @@ static int handle_alias(int *argcp, const char
> ***argv) alias_string = alias_lookup(alias_command);
>  	if (alias_string) {
>  		if (alias_string[0] == '!') {
> +			const char **alias_argv;
> +			int argc = *argcp, i;
> +
>  			commit_pager_choice();
> -			if (*argcp > 1) {
> -				struct strbuf buf;
> -
> -				strbuf_init(&buf, PATH_MAX);
> -				strbuf_addstr(&buf, alias_string);
> -				sq_quote_argv(&buf, (*argv) + 1, PATH_MAX);
> -				free(alias_string);
> -				alias_string = buf.buf;
> -			}
> -			trace_printf("trace: alias to shell cmd: %s => %s\n",
> -				     alias_command, alias_string + 1);
> -			ret = system(alias_string + 1);
> -			if (ret >= 0 && WIFEXITED(ret) &&
> -			    WEXITSTATUS(ret) != 127)
> -				exit(WEXITSTATUS(ret));
> +
> +			/* build alias_argv */
> +			alias_argv = xmalloc(sizeof(char *) * argc + 1);
> +			alias_argv[0] = alias_string + 1;
> +			for (i = 1; i < argc; ++i)
> +				alias_argv[i] = (*argv)[i];
> +			alias_argv[argc] = NULL;
> +
> +			ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);
> +			if (ret >= 0)   /* normal exit */
> +				exit(ret);
> +
>  			die("Failed to run '%s' when expanding alias '%s'",
>  			    alias_string + 1, alias_command);

At this point, errno has a meaning. I'd perhaps change this to:

			die_errno("While expanding alias '%s': '%s'",
				alias_command, alias_string + 1);

-- Hannes
--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]