diff options
-rw-r--r-- | src/luarocks/fs/unix.lua | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua index 979fd166..88bafaf6 100644 --- a/src/luarocks/fs/unix.lua +++ b/src/luarocks/fs/unix.lua | |||
@@ -71,30 +71,16 @@ function is_actual_binary(filename) | |||
71 | return false | 71 | return false |
72 | end | 72 | end |
73 | local file = io.open(filename) | 73 | local file = io.open(filename) |
74 | if file then | 74 | if not file then |
75 | local found = false | 75 | return true |
76 | local first = file:read() | 76 | end |
77 | if not first then | 77 | local first = file:read(2) |
78 | file:close() | 78 | file:close() |
79 | util.printerr("Warning: could not read "..filename) | 79 | if not first then |
80 | return false | 80 | util.printerr("Warning: could not read "..filename) |
81 | end | ||
82 | if first:match("#!.*lua") then | ||
83 | file:close() | ||
84 | return true | ||
85 | elseif first:match("#!/bin/sh") then | ||
86 | local line = file:read() | ||
87 | line = file:read() | ||
88 | if not(line and line:match("LUA_PATH")) then | ||
89 | file:close() | ||
90 | return true | ||
91 | end | ||
92 | end | ||
93 | file:close() | ||
94 | else | ||
95 | return true | 81 | return true |
96 | end | 82 | end |
97 | return false | 83 | return first ~= "#!" |
98 | end | 84 | end |
99 | 85 | ||
100 | function copy_binary(filename, dest) | 86 | function copy_binary(filename, dest) |