Re: [RFC PATCH v2] Allow aliases that include other aliases

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

 



Tim Schumacher <timschumi@xxxxxx> writes:

> @@ -691,17 +693,34 @@ static int run_argv(int *argcp, const char ***argv)
>  		/* .. then try the external ones */
>  		execv_dashed_external(*argv);
>  
> +		/* Increase the array size and add the current
> +		 * command to it.
> +		 */
> +		cmd_list_alloc += strlen(*argv[0]) + 1;
> +		REALLOC_ARRAY(cmd_list, cmd_list_alloc);
> +		cmd_list[done_alias] = *argv[0];
> +
> +		/* Search the array for occurrences of that command,
> +		 * abort if something has been found.
> +		 */
> +		for (int i = 0; i < done_alias; i++) {
> +			if (!strcmp(cmd_list[i], *argv[0])) {
> +				die("loop alias: %s is called twice",
> +				    cmd_list[done_alias]);
> +			}
> +		}
> +

Wouldn't all of the above become three or four lines that is so
clear that there is no need for any comment if you used string-list,
perhaps?

>  		/* It could be an alias -- this works around the insanity
>  		 * of overriding "git log" with "git show" by having
>  		 * alias.log = show
>  		 */

	/*
	 * Style: our multi-line comment begins with and ends with
	 * slash-asterisk and asterisk-slash on their own lines.
	 */

> -		if (done_alias)
> -			break;
>  		if (!handle_alias(argcp, argv))
>  			break;
> -		done_alias = 1;
> +		done_alias++;
>  	}
>  
> +	free(cmd_list);
> +
>  	return done_alias;
>  }



[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]

  Powered by Linux