From cb558e4bd2b817bc72275c2bbd90dfe9fe380af9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 8 Dec 2020 22:40:54 +0300 Subject: Add export script pseudo-builtin --- libbuild2/script/parser.cxx | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'libbuild2/script/parser.cxx') diff --git a/libbuild2/script/parser.cxx b/libbuild2/script/parser.cxx index b4184ea..41d3092 100644 --- a/libbuild2/script/parser.cxx +++ b/libbuild2/script/parser.cxx @@ -1437,36 +1437,22 @@ namespace build2 } else if (optional v = str ("--unset", "-u")) { - if (v->find ('=') != string::npos) - fail (i->second) << "env: invalid value '" << *v << "' for " - << "option '" << o << "': contains '='"; + verify_environment_var_name (*v, o.c_str (), "env: ", i->second); - r.variables.push_back (move (*v)); + r.variables.add (move (*v)); } else break; } - // Parse the variable sets (from arguments). + // Parse arguments (variable sets). // for (; i != e; ++i) { string& a (i->first); + verify_environment_var_assignment (a, "env: ", i->second); - // Validate the variable assignment. - // - size_t p (a.find ('=')); - - if (p == string::npos) - fail (i->second) - << "env: expected variable assignment instead of '" << a << "'"; - - if (p == 0) - fail (i->second) << "env: empty variable name"; - - // Add the variable set to the resulting list. - // - r.variables.push_back (move (a)); + r.variables.add (move (a)); } return r; -- cgit v1.1