git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC] split_cmdline: Allow caller to access error string

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 11, 2010, 18:31 UTC
Message-ID
<7vhbj1yp9q.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1281158019-25995-1-git-send-email-gdb@mit.edu>
Greg Brockman <gdb@MIT.EDU> writes:
Show 13 quoted lines
> This allows the caller to add its own error message to that returned
> by split_cmdline.  Thus error output following a failed split_cmdline
> can be of the form
>
> fatal: Bad alias.test string: cmdline ends with \
>
> rather than
>
> error: cmdline ends with \
> fatal: Bad alias.test string
>
> Signed-off-by: Greg Brockman <gdb@mit.edu>
> ---
Show 27 quoted lines
> diff --git a/alias.c b/alias.c
> index 372b7d8..6f771cb 100644
> --- a/alias.c
> +++ b/alias.c
> @@ -1,7 +1,9 @@
> ...
> +#define SPLIT_CMDLINE_BAD_ENDING 1
> +#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2
> +static const char *split_cmdline_errors = { "cmdline ends with \\", "unclosed quote" };
> ...
> @@ -53,7 +55,7 @@ int split_cmdline(char *cmdline, const char ***argv)
>  				if (!c) {
>  					free(*argv);
>  					*argv = NULL;
> -					return error("cmdline ends with \\");
> +					return -SPLIT_CMDLINE_BAD_ENDING;
>  				}
>  			}
>  			cmdline[dst++] = c;
>...
> @@ -75,3 +77,6 @@ int split_cmdline(char *cmdline, const char ***argv)
>  	return count;
>  }
>  
> +const char *split_cmdline_strerror(int split_cmdline_errno) {
> +	return split_cmdline_errors[-split_cmdline_errno-1];
> +}
Looks like a reasonable way to go.  Thanks.
Previous: Greg Brockman
Message 2 of 2 in “split_cmdline: Allow caller to access error string”
  1. split_cmdline: Allow caller to access error stringGreg Brockman, Aug 7, 2010
  2. Junio C HamanoAug 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.