From 884d3cefd3b5d5ba5c6f5af0f0c87168005af3f3 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Wed, 5 Dec 2018 16:42:30 +0000 Subject: [PATCH] add option to quote multiple values at once --- zpm-quote.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zpm-quote.c b/zpm-quote.c index 1aea24b..d0006e3 100644 --- a/zpm-quote.c +++ b/zpm-quote.c @@ -65,12 +65,15 @@ int main(int ac, char **av) { int ch = '\''; int opt, shellmode = 0, addquotes = 0, ident = 0; char *repl = "''"; + int count = 0; + char *separator = "\n"; - while ((opt = getopt(ac, av, "sqi")) != -1) { + while ((opt = getopt(ac, av, "sqid:")) != -1) { switch (opt) { case 's': shellmode = 1; break; case 'q': addquotes = 1; break; case 'i': ident = 1; break; + case 'd': separator = optarg; break; default: exit(EXIT_FAILURE); break; @@ -85,10 +88,13 @@ int main(int ac, char **av) { repl = "\"\""; } + count = 0; for (i=argn;i 0 ? separator : "", quoted); free(quoted); + count++; } + printf("\n"); return 0; } -- 2.40.0