diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-01-12 22:41:42 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-01-12 22:41:42 -0200 |
commit | 8d588f9c0f6c884c972c65635f3b503403d293f8 (patch) | |
tree | 90f55aeb65353d2c5b1a6ecc785153346312909c | |
parent | 1885a7f7100c2ec135878ab29ebb5f09da3b7507 (diff) | |
download | luarocks-8d588f9c0f6c884c972c65635f3b503403d293f8.tar.gz luarocks-8d588f9c0f6c884c972c65635f3b503403d293f8.tar.bz2 luarocks-8d588f9c0f6c884c972c65635f3b503403d293f8.zip |
Catch error if filename is a directory
-rw-r--r-- | src/luarocks/persist.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/luarocks/persist.lua b/src/luarocks/persist.lua index 87db96b2..39e1e71c 100644 --- a/src/luarocks/persist.lua +++ b/src/luarocks/persist.lua | |||
@@ -14,8 +14,12 @@ local function run_file(filename, env) | |||
14 | if not fd then | 14 | if not fd then |
15 | return nil, err, "open" | 15 | return nil, err, "open" |
16 | end | 16 | end |
17 | local str = fd:read("*a"):gsub("^#![^\n]*\n", "") | 17 | local str, err = fd:read("*a") |
18 | fd:close() | 18 | fd:close() |
19 | if not str then | ||
20 | return nil, err, "open" | ||
21 | end | ||
22 | str = str:gsub("^#![^\n]*\n", "") | ||
19 | local chunk, ran | 23 | local chunk, ran |
20 | if _VERSION == "Lua 5.1" then -- Lua 5.1 | 24 | if _VERSION == "Lua 5.1" then -- Lua 5.1 |
21 | chunk, err = loadstring(str, filename) | 25 | chunk, err = loadstring(str, filename) |