From 31309f3d2d2c884798f1be9e43c72d95a4d2caef Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sat, 23 Sep 2017 18:19:01 +1000 Subject: [PATCH] moved the run-related functions into the fs library --- modules/lib/fs.lua | 21 +++++++++++++++++++++ modules/lib/shutil.lua | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/lib/fs.lua b/modules/lib/fs.lua index 7618639..8e1063f 100644 --- a/modules/lib/fs.lua +++ b/modules/lib/fs.lua @@ -248,3 +248,24 @@ function fs.mv(s,d) fs.cp(s,d) fs.rm(s) end +function loadfile(fn) + local f=io.open(fn,"rb") + if not f then return false, "cannot read file" end + local S=f:read("*a") + f:close() + return load(S,"=("..fn..")","bt",os.genenv()) +end +function run(fn,...) + local lf = loadfile(fn) + if not lf then return false, "cannot load file" end + local r = {pcall(lf,...)} + if r[1] == true then + table.remove(r,1) + end + print(table.unpack(r)) +end +function srun(fn,...) + local lf = loadfile(fn) + if not lf then return false, "cannot load file" end + spawn(fn,print(pcall(lf,...))) +end diff --git a/modules/lib/shutil.lua b/modules/lib/shutil.lua index 9b81b4a..c960ea5 100644 --- a/modules/lib/shutil.lua +++ b/modules/lib/shutil.lua @@ -8,24 +8,3 @@ function shutil.genenv() end return et end -function loadfile(fn) - local f=io.open(fn,"rb") - if not f then return false, "cannot read file" end - local S=f:read("*a") - f:close() - return load(S,"=("..fn..")","bt",os.genenv()) -end -function run(fn,...) - local lf = loadfile(fn) - if not lf then return false, "cannot load file" end - local r = {pcall(lf,...)} - if r[1] == true then - table.remove(r,1) - end - print(table.unpack(r)) -end -function srun(fn,...) - local lf = loadfile(fn) - if not lf then return false, "cannot load file" end - spawn(fn,print(pcall(lf,...))) -end