Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hishamhm/1865176 to your computer and use it in GitHub Desktop.
Save hishamhm/1865176 to your computer and use it in GitHub Desktop.
LuaRocks 2.0.8-rc1: Simplify detection of binary files for determining arch suffix of packed rocks
diff --git a/src/luarocks/fs/unix.lua b/src/luarocks/fs/unix.lua
index 979fd16..88bafaf 100644
--- a/src/luarocks/fs/unix.lua
+++ b/src/luarocks/fs/unix.lua
@@ -71,30 +71,16 @@ function is_actual_binary(filename)
return false
end
local file = io.open(filename)
- if file then
- local found = false
- local first = file:read()
- if not first then
- file:close()
- util.printerr("Warning: could not read "..filename)
- return false
- end
- if first:match("#!.*lua") then
- file:close()
- return true
- elseif first:match("#!/bin/sh") then
- local line = file:read()
- line = file:read()
- if not(line and line:match("LUA_PATH")) then
- file:close()
- return true
- end
- end
- file:close()
- else
+ if not file then
+ return true
+ end
+ local first = file:read(2)
+ file:close()
+ if not first then
+ util.printerr("Warning: could not read "..filename)
return true
end
- return false
+ return first ~= "#!"
end
function copy_binary(filename, dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment