From d7e297844c88022cf10ebeb14759a8df7dd539c4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 24 Jul 2018 17:36:45 -0700 Subject: Fixed stdin handling. --- files.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'files.lua') diff --git a/files.lua b/files.lua index cda361d..0504faf 100644 --- a/files.lua +++ b/files.lua @@ -26,6 +26,7 @@ local _FILE_CACHE = setmetatable({ }, { }) local _BROWSE_CACHE = { } Files.spoof = function(filename, contents) + print("SPOOFING " .. tostring(filename)) _SPOOFED_FILES[filename] = contents return contents end @@ -65,6 +66,9 @@ Files.exists = function(path) if _SPOOFED_FILES[path] then return true end + if path == 'stdin' then + return true + end if run_cmd("ls " .. tostring(sanitize(path))) then return true end @@ -116,7 +120,7 @@ if ok then end browse = function(filename) if not (_BROWSE_CACHE[filename]) then - if _SPOOFED_FILES[filename] then + if _SPOOFED_FILES[filename] or filename == 'stdin' then _BROWSE_CACHE[filename] = { filename } @@ -174,11 +178,17 @@ Files.walk = function(path, flush_cache) _BROWSE_CACHE = { } end local files - for nomsupath in package.nomsupath:gmatch("[^;]+") do - do - files = browse(nomsupath .. "/" .. path) - if files then - break + if path == 'stdin' then + files = { + path + } + else + for nomsupath in package.nomsupath:gmatch("[^;]+") do + do + files = browse(nomsupath .. "/" .. path) + if files then + break + end end end end -- cgit v1.2.3