aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/script.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-25 11:19:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-25 11:19:40 +0200
commita3dad2118fb3925ef4f9baa90cea0dfd44ca93c6 (patch)
tree54748b5d85cab7bfb70a7baf66fe902c82cf3d66 /build2/test/script/script.cxx
parent28f8338ded34f160e0083da9be4679bc778be7ca (diff)
Allow here-document end marker to be wholly quoted
Diffstat (limited to 'build2/test/script/script.cxx')
-rw-r--r--build2/test/script/script.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/build2/test/script/script.cxx b/build2/test/script/script.cxx
index b128077..8fb8115 100644
--- a/build2/test/script/script.cxx
+++ b/build2/test/script/script.cxx
@@ -38,14 +38,16 @@ namespace build2
}
// Quote if empty or contains spaces or any of the special characters.
+ // Note that we use single quotes since double quotes still allow
+ // expansion.
//
- // @@ What if it contains quotes, escapes?
+ // @@ What if it contains single quotes?
//
static void
to_stream_q (ostream& o, const string& s)
{
- if (s.empty () || s.find_first_of (" |&<>=") != string::npos)
- o << '"' << s << '"';
+ if (s.empty () || s.find_first_of (" |&<>=\\\"") != string::npos)
+ o << '\'' << s << '\'';
else
o << s;
};
@@ -100,7 +102,8 @@ namespace build2
// Add another '>' or '<'. Note that here end marker never
// needs to be quoted.
//
- o << d << (nl ? "" : ":") << r.doc.end;
+ o << d << (nl ? "" : ":");
+ to_stream_q (o, r.doc.end);
break;
}
case redirect_type::file: