From 84a8b5e9af2df4ed7f7860a6768daf83f72724ca Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 4 Feb 2014 10:37:10 -0500 Subject: [PATCH] nix-instantiate --eval-only --read-write-mode: Don't depend on ordering Signed-off-by: Shea Levy --- src/nix-instantiate/nix-instantiate.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 6a93acf39..e9f1284eb 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -97,23 +97,19 @@ void run(Strings args) bool strict = false; Strings attrPaths; Bindings autoArgs; + bool wantsReadWrite = false; for (Strings::iterator i = args.begin(); i != args.end(); ) { string arg = *i++; if (arg == "-") readStdin = true; - else if (arg == "--eval-only") { - settings.readOnlyMode = true; + else if (arg == "--eval-only") evalOnly = true; - } - else if (arg == "--read-write-mode") { - settings.readOnlyMode = false; - } - else if (arg == "--parse-only") { - settings.readOnlyMode = true; + else if (arg == "--read-write-mode") + wantsReadWrite = true; + else if (arg == "--parse-only") parseOnly = evalOnly = true; - } else if (arg == "--find-file") findFile = true; else if (arg == "--attr" || arg == "-A") { @@ -146,6 +142,9 @@ void run(Strings args) files.push_back(arg); } + if (evalOnly && !wantsReadWrite) + settings.readOnlyMode = true; + if (attrPaths.empty()) attrPaths.push_back(""); if (findFile) {