aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-03-31 11:58:41 -0400
committerShea Levy <shea@shealevy.com>2017-03-31 11:58:41 -0400
commit3ecb09a40a8500d1052b087295b589ca4856fd7a (patch)
tree22ea081f11dcd7040764005563f2bfb3e7d29374 /src/libexpr/primops.cc
parentd299bd710a5c47b54a6f166c7e26608c10f41456 (diff)
builtins.exec: Make the argument just a list
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc31
1 files changed, 9 insertions, 22 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index a98da737e..615cc8138 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -181,30 +181,17 @@ static void prim_importNative(EvalState & state, const Pos & pos, Value * * args
/* Execute a program and parse its output */
static void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
- state.forceAttrs(*args[0], pos);
- auto sProgram = state.symbols.create("program");
- auto sArguments = state.symbols.create("arguments");
+ state.forceList(*args[0], pos);
+ auto elems = args[0]->listElems();
+ auto count = args[0]->listSize();
+ if (count == 0) {
+ throw EvalError(format("at least one argument to 'exec' required, at %1%") % pos);
+ }
PathSet context;
- string program;
- bool programSet = false;
+ auto program = state.coerceToString(pos, *elems[0], context, false, false);
Strings commandArgs;
- for (auto & attr : *args[0]->attrs) {
- if (attr.name == sProgram) {
- program = state.coerceToString(*attr.pos, *attr.value, context, false, false);
- programSet = true;
- } else if (attr.name == sArguments) {
- state.forceList(*attr.value, *attr.pos);
- auto elems = attr.value->listElems();
- for (unsigned int i = 0; i < attr.value->listSize(); ++i) {
- commandArgs.emplace_back(state.coerceToString(*attr.pos, *elems[i], context, false, false));
- }
- } else {
- throw EvalError(format("unexpected attribute ‘%1%’ in argument to builtins.exec, at %2%")
- % attr.name % pos);
- }
- }
- if (!programSet) {
- throw EvalError(format("attribute ‘programSet’ required, at %1%") % pos);
+ for (unsigned int i = 1; i < args[0]->listSize(); ++i) {
+ commandArgs.emplace_back(state.coerceToString(pos, *elems[i], context, false, false));
}
try {
state.realiseContext(context);