From b3782d2dc8f872c43fcf53b9436c4e881d3f1e2d Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 4 Jun 2020 07:12:05 +0000 Subject: Instead of using a custom parse function to process {}, treat it as a set of statements and parse with yacc, then convert back to a string as the last step. This means the rules are consistent inside and outside {}, %if and friends work at the right time, and the final result isn't littered with unnecessary newlines. --- arguments.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'arguments.c') diff --git a/arguments.c b/arguments.c index ef67107d..0495aa0e 100644 --- a/arguments.c +++ b/arguments.c @@ -227,6 +227,11 @@ args_escape(const char *s) return (escaped); } + if (strchr(s, ' ') != NULL && strchr(s, '\'') == NULL) { + xasprintf(&escaped, "'%s'", s); + return (escaped); + } + flags = VIS_OCTAL|VIS_CSTYLE|VIS_TAB|VIS_NL; if (s[strcspn(s, quoted)] != '\0') flags |= VIS_DQ; -- cgit