about summary refs log tree commit diff
path: root/src/nix/run.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-10-24T10·45+0200
committerEelco Dolstra <edolstra@gmail.com>2017-10-24T10·58+0200
commit0d59f1ca49c9f7f3b2edaadcf590360ec66a6257 (patch)
treea03d53d84fb61eb354e2634705d8a076f0c1c76d /src/nix/run.cc
parent25f32625e2f2a3a1e1b3a3811da82f21c3a3b880 (diff)
nix: Respect -I, --arg, --argstr
Also, random cleanup to argument handling.
Diffstat (limited to 'src/nix/run.cc')
-rw-r--r--src/nix/run.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc
index 2f93ca351502..6657a86314bf 100644
--- a/src/nix/run.cc
+++ b/src/nix/run.cc
@@ -20,7 +20,7 @@ extern char * * environ;
 
 struct CmdRun : InstallablesCommand
 {
-    Strings command = { "bash" };
+    std::vector<std::string> command = { "bash" };
     StringSet keep, unset;
     bool ignoreEnvironment = false;
 
@@ -32,7 +32,7 @@ struct CmdRun : InstallablesCommand
             .description("command and arguments to be executed; defaults to 'bash'")
             .arity(ArityAny)
             .labels({"command", "args"})
-            .handler([&](Strings ss) {
+            .handler([&](std::vector<std::string> ss) {
                 if (ss.empty()) throw UsageError("--command requires at least one argument");
                 command = ss;
             });
@@ -49,7 +49,7 @@ struct CmdRun : InstallablesCommand
             .description("keep specified environment variable")
             .arity(1)
             .labels({"name"})
-            .handler([&](Strings ss) { keep.insert(ss.front()); });
+            .handler([&](std::vector<std::string> ss) { keep.insert(ss.front()); });
 
         mkFlag()
             .longName("unset")
@@ -57,7 +57,7 @@ struct CmdRun : InstallablesCommand
             .description("unset specified environment variable")
             .arity(1)
             .labels({"name"})
-            .handler([&](Strings ss) { unset.insert(ss.front()); });
+            .handler([&](std::vector<std::string> ss) { unset.insert(ss.front()); });
     }
 
     std::string name() override
@@ -126,7 +126,8 @@ struct CmdRun : InstallablesCommand
         setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1);
 
         std::string cmd = *command.begin();
-        Strings args = command;
+        Strings args;
+        for (auto & arg : command) args.push_back(arg);
 
         stopProgressBar();