about summary refs log tree commit diff
path: root/src/nix-build/nix-build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-18T11·28+0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-18T11·28+0200
commit84f112b1c8d3c5181b7a9b11d309f14f1709480d (patch)
treef1bdc13776731b564e28b26729b4e9fb9b8c8183 /src/nix-build/nix-build.cc
parentaca4f7dff0ee615164668e923deaf5cc96ab1c8a (diff)
nix-shell: Ignore readFile() errors
Fixes #1563.
Diffstat (limited to 'src/nix-build/nix-build.cc')
-rwxr-xr-xsrc/nix-build/nix-build.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index b36933a0ac21..a3d3c8007be6 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -105,12 +105,12 @@ void mainWrapped(int argc, char * * argv)
     for (int i = 1; i < argc; ++i)
         args.push_back(argv[i]);
 
-    // Heuristic to see if we're invoked as a shebang script, namely, if we
-    // have a single argument, it's the name of an executable file, and it
-    // starts with "#!".
+    // Heuristic to see if we're invoked as a shebang script, namely,
+    // if we have at least one argument, it's the name of an
+    // executable file, and it starts with "#!".
     if (runEnv && argc > 1 && !std::regex_search(argv[1], std::regex("nix-shell"))) {
         script = argv[1];
-        if (access(script.c_str(), F_OK) == 0 && access(script.c_str(), X_OK) == 0) {
+        try {
             auto lines = tokenizeString<Strings>(readFile(script), "\n");
             if (std::regex_search(lines.front(), std::regex("^#!"))) {
                 lines.pop_front();
@@ -126,7 +126,7 @@ void mainWrapped(int argc, char * * argv)
                             args.push_back(word);
                 }
             }
-        }
+        } catch (SysError &) { }
     }
 
     parseCmdLine(myName, args, [&](Strings::iterator & arg, const Strings::iterator & end) {