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;
repl = "\"\"";
}
+ count = 0;
for (i=argn;i<ac;i++) {
quoted = quote(av[i], ch, repl, addquotes);
- printf("%s\n", quoted);
+ printf("%s%s", count > 0 ? separator : "", quoted);
free(quoted);
+ count++;
}
+ printf("\n");
return 0;
}