aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-07 10:52:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-07 10:52:01 +0200
commite3ce9cc60846cc2e4e4775f6d24c28089bad30ff (patch)
tree159a22223aa265bb72e6f751bece56991b895e7a /build2/test/script/parser.cxx
parent14dafdb39f1ce9eb205ecc978b7255c4cfc72446 (diff)
Only do effective escaping when re-parsing expansions in testscript
Doing unconditional escaping messes up expansions that are Windows paths.
Diffstat (limited to 'build2/test/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index df1cd9f..0cc54f7 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -1595,7 +1595,7 @@ namespace build2
// interesting characters (operators plus quotes/escapes),
// then no need to re-lex.
//
- // NOTE: updated quoting (script.cxx:to_stream_q()) if adding
+ // NOTE: update quoting (script.cxx:to_stream_q()) if adding
// any new characters.
//
if (q || s.find_first_of ("|&<>\'\"\\") == string::npos)
@@ -1631,8 +1631,20 @@ namespace build2
name = path (move (n));
}
+ // When re-parsing we do "effective escaping" and only for
+ // ['"\] (quotes plus the backslash itself). In particular,
+ // there is no way to escape redirects, operators, etc. The
+ // idea is to prefer quoting except for passing literal
+ // quotes, for example:
+ //
+ // args = \"&foo\"
+ // cmd $args # cmd &foo
+ //
+ // args = 'x=\"foo bar\"'
+ // cmd $args # cmd x="foo bar"
+ //
istringstream is (s);
- lexer lex (is, name, lexer_mode::command_line);
+ lexer lex (is, name, lexer_mode::command_line, "\'\"\\");
// Treat the first "sub-token" as always separated from what
// we saw earlier.