diff options
author | Ben Burdette <bburdette@gmail.com> | 2020-05-11 14:35:30 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2020-05-11 14:35:30 -0600 |
commit | 59b1f5c70150a81c7a6fa0dc3309a9d44e9621f8 (patch) | |
tree | 542fc01dfaffdf7acbc5c1a89fd41a0918396f4b /src/nix/run.cc | |
parent | 536bbf53e12c80f52c2679aec734d895b0058f5b (diff) | |
parent | 5bdb67c84308a8cc78ac633d27b94eca87ea4390 (diff) |
Merge branch 'master' into errors-phase-2
Diffstat (limited to 'src/nix/run.cc')
-rw-r--r-- | src/nix/run.cc | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc index d790979a4..c9b69aec7 100644 --- a/src/nix/run.cc +++ b/src/nix/run.cc @@ -57,22 +57,22 @@ struct RunCommon : virtual Command } }; -struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment +struct CmdShell : InstallablesCommand, RunCommon, MixEnvironment { - std::vector<std::string> command = { "bash" }; + std::vector<std::string> command = { getEnv("SHELL").value_or("bash") }; - CmdRun() + CmdShell() { - mkFlag() - .longName("command") - .shortName('c') - .description("command and arguments to be executed; defaults to 'bash'") - .labels({"command", "args"}) - .arity(ArityAny) - .handler([&](std::vector<std::string> ss) { + addFlag({ + .longName = "command", + .shortName = 'c', + .description = "command and arguments to be executed; defaults to '$SHELL'", + .labels = {"command", "args"}, + .handler = {[&](std::vector<std::string> ss) { if (ss.empty()) throw UsageError("--command requires at least one argument"); command = ss; - }); + }} + }); } std::string description() override @@ -85,19 +85,19 @@ struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment return { Example{ "To start a shell providing GNU Hello from NixOS 17.03:", - "nix run -f channel:nixos-17.03 hello" + "nix shell -f channel:nixos-17.03 hello" }, Example{ "To start a shell providing youtube-dl from your 'nixpkgs' channel:", - "nix run nixpkgs.youtube-dl" + "nix shell nixpkgs.youtube-dl" }, Example{ "To run GNU Hello:", - "nix run nixpkgs.hello -c hello --greeting 'Hi everybody!'" + "nix shell nixpkgs.hello -c hello --greeting 'Hi everybody!'" }, Example{ "To run GNU Hello in a chroot store:", - "nix run --store ~/my-nix nixpkgs.hello -c hello" + "nix shell --store ~/my-nix nixpkgs.hello -c hello" }, }; } @@ -141,7 +141,7 @@ struct CmdRun : InstallablesCommand, RunCommon, MixEnvironment } }; -static auto r1 = registerCommand<CmdRun>("run"); +static auto r1 = registerCommand<CmdShell>("shell"); void chrootHelper(int argc, char * * argv) { |