chiark / gitweb /
core: interpret \; token in ExecStart as escaped ;
authorOleksii Shevchuk <alxchk@gmail.com>
Sat, 3 Nov 2012 19:52:02 +0000 (21:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Nov 2012 15:01:10 +0000 (16:01 +0100)
Some commands (like 'find') take a semicolon as separate arg. With
current parser implementation there is no way to pass one.

Patch adds token \;

src/core/load-fragment.c
src/test/test-unit-file.c

index 5803044..4dc5c52 100644 (file)
@@ -483,6 +483,8 @@ int config_parse_exec(
                 FOREACH_WORD_QUOTED(w, l, rvalue, state) {
                         if (strncmp(w, ";", MAX(l, 1U)) == 0)
                                 break;
                 FOREACH_WORD_QUOTED(w, l, rvalue, state) {
                         if (strncmp(w, ";", MAX(l, 1U)) == 0)
                                 break;
+                        else if (strncmp(w, "\\;", MAX(l, 1U)) == 0)
+                                w ++;
 
                         if (honour_argv0 && w == rvalue) {
                                 assert(!path);
 
                         if (honour_argv0 && w == rvalue) {
                                 assert(!path);
index bb5cbdf..bca8a69 100644 (file)
@@ -138,6 +138,16 @@ static void test_config_parse_exec(void) {
 
         assert_se(c1->command_next == NULL);
 
 
         assert_se(c1->command_next == NULL);
 
+        /* escaped semicolon */
+        r = config_parse_exec("fake", 5, "section",
+                              "LValue", 0,
+                              "/usr/bin/find \\;",
+                              &c, NULL);
+        assert_se(r >= 0);
+        c1 = c1->command_next;
+        check_execcommand(c1,
+                          "/usr/bin/find", "/usr/bin/find", ";", false);
+
         exec_command_free_list(c);
 }
 
         exec_command_free_list(c);
 }