Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-03-29 13:44:52 +0400
committerJunio C Hamano <gitster@pobox.com>2009-03-30 12:22:53 +0400
commiteaa759b9141f125d7e55a4b08b60497845d3c52e (patch)
treea10153bea4a6ae128be98c08d55f6b5a66fbe912 /quote.c
parentebbc088e13e1bf0dbf8eb08b00519602c176f864 (diff)
quote: add "sq_dequote_to_argv" to put unwrapped args in an argv array
This new function unwraps the space separated shell quoted elements in its first argument and places them in the argv array passed as its second argument. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/quote.c b/quote.c
index ea49c7a99f..7a49fcf696 100644
--- a/quote.c
+++ b/quote.c
@@ -120,6 +120,23 @@ char *sq_dequote(char *arg)
return sq_dequote_step(arg, NULL);
}
+int sq_dequote_to_argv(char *arg, const char ***argv, int *nr, int *alloc)
+{
+ char *next = arg;
+
+ if (!*arg)
+ return 0;
+ do {
+ char *dequoted = sq_dequote_step(next, &next);
+ if (!dequoted)
+ return -1;
+ ALLOC_GROW(*argv, *nr + 1, *alloc);
+ (*argv)[(*nr)++] = dequoted;
+ } while (next);
+
+ return 0;
+}
+
/* 1 means: quote as octal
* 0 means: quote as octal if (quote_path_fully)
* -1 means: never quote