From c7e978427594ed0cd895eb7f8bfa1b658bd02591 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 22 Feb 2012 16:59:30 -0200 Subject: Simplify detection of binary files for determining arch suffix of packed rocks. Closes #61. --- src/luarocks/fs/unix.lua | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src') 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) 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) -- cgit v1.2.3-55-g6feb