aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-27 10:04:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:36 +0200
commit33c5d3e0fce306631bad78ba3a4a87bb1f719fa5 (patch)
treeadd88005988d9c023d7e1f0ea7ffcc25e16681f2
parent023d8d8b040d5fce821080b016b4ce25eb67550d (diff)
Minor changes to merge redirect code
-rw-r--r--build2/test/script/parser.cxx20
-rw-r--r--build2/test/script/script2
2 files changed, 10 insertions, 12 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index 70f1ef2..2d9a065 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -599,17 +599,16 @@ namespace build2
try
{
size_t n;
- if (stoi (w, &n) != fd || n != w.size ())
- throw invalid_argument (string ());
- }
- catch (const exception&)
- {
- fail (l) << "invalid " << (fd == 1 ? "stderr" : "stdout")
- << " merge redirect file descriptor '" << w << "'" <<
- info << "must be " << fd;
+ if (stoi (w, &n) == fd || n == w.size ())
+ {
+ r.fd = fd;
+ return;
+ }
}
+ catch (const exception&) {} // Fall through.
- r.fd = fd;
+ fail (l) << (fd == 1 ? "stderr" : "stdout") << " merge redirect "
+ << "file descriptor must be " << fd;
};
auto add_here_str = [&nn] (redirect& r, string&& w)
@@ -1139,8 +1138,7 @@ namespace build2
if (c.out.type == redirect_type::merge &&
c.err.type == redirect_type::merge)
- fail (l) << "stdout and stderr merge redirects" <<
- info << "should not be specified at the same time";
+ fail (l) << "stdout and stderr redirected to each other";
}
// While we no longer need to recognize command line operators, we
diff --git a/build2/test/script/script b/build2/test/script/script
index f0d8f21..a21f0c6 100644
--- a/build2/test/script/script
+++ b/build2/test/script/script
@@ -68,7 +68,7 @@ namespace build2
union
{
- int fd; // Used with 'merge' type.
+ int fd; // Merge-to descriptor.
string str; // Note: includes trailing newline, if required.
doc_type doc;
file_type file;