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.moon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'nomsu.moon') diff --git a/nomsu.moon b/nomsu.moon index f7fc601..50a95d9 100755 --- a/nomsu.moon +++ b/nomsu.moon @@ -77,7 +77,13 @@ all_files = (path)-> return iterate_single, path -- TODO: improve sanitization path = path\gsub("\\","\\\\")\gsub("`","")\gsub('"','\\"')\gsub("$","") - return io.popen('find -L "'..path..'" -type f -name "*.nom"')\lines! + return coroutine.wrap -> + f = io.popen('find -L "'..path..'" -type f -name "*.nom"') + for line in f\lines! + coroutine.yield(line) + success = f\close! + unless success + error("Invalid file path: "..tostring(path)) line_counter = re.compile([[ lines <- {| line (%nl line)* |} -- cgit v1.2.3