From 0c07968e0716745f7b510a76e94ccf0910e4c4e7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 24 May 2018 15:51:06 -0700 Subject: Added error checking for bad paths. --- nomsu.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index 07cd17f..10a3b66 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -88,7 +88,16 @@ all_files = function(path) return iterate_single, path end path = path:gsub("\\", "\\\\"):gsub("`", ""):gsub('"', '\\"'):gsub("$", "") - return io.popen('find -L "' .. path .. '" -type f -name "*.nom"'):lines() + return coroutine.wrap(function() + local f = io.popen('find -L "' .. path .. '" -type f -name "*.nom"') + for line in f:lines() do + coroutine.yield(line) + end + local success = f:close() + if not (success) then + return error("Invalid file path: " .. tostring(path)) + end + end) end local line_counter = re.compile([[ lines <- {| line (%nl line)* |} line <- {} (!%nl .)* -- cgit v1.2.3