From c698ec1f220f9be4c4184532f0a6c2a9370f3839 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Sun, 1 Jan 2017 18:42:06 +0200 Subject: nix-shell: Fix 'nix-shell -i' The 'args' variable here is shadowing one in the outer scope and its contents end up unused. This causes any '#! nix-shell' lines to effectively be ignored. The intention here was to clear the args vector, as far as I can tell (and it seems to work). --- src/nix-build/nix-build.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nix-build/nix-build.cc') diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 08c6793577a4..4d86f394bc92 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -117,7 +117,7 @@ int main(int argc, char ** argv) inShebang = true; for (int i = 2; i < argc - 1; ++i) savedArgs.push_back(argv[i]); - std::vector args; + args.clear(); for (auto line : lines) { line = chomp(line); std::smatch match; -- cgit 1.4.1 From 018f884ffd834ee339e9b4182b4537a3cd80ee28 Mon Sep 17 00:00:00 2001 From: Tuomas Tynkkynen Date: Tue, 3 Jan 2017 09:59:09 +0200 Subject: nix-shell: Don't act interactive in shebangs I had observed that 'bash --rcfile' would do nothing in a non-interactive context and cause nothing to be executed if a script using nix-shell shebangs were run in a non-interactive context. --- src/nix-build/nix-build.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/nix-build/nix-build.cc') diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc index 4d86f394bc92..ef959fa00938 100755 --- a/src/nix-build/nix-build.cc +++ b/src/nix-build/nix-build.cc @@ -276,6 +276,7 @@ int main(int argc, char ** argv) if (n >= args.size()) { throw UsageError(format("%1% requires an argument") % arg); } + interactive = false; auto interpreter = args[n]; auto execArgs = ""; -- cgit 1.4.1