diff --git a/sys/apps/shell.lua b/sys/apps/shell.lua index 52dcc33..54eeb2c 100644 --- a/sys/apps/shell.lua +++ b/sys/apps/shell.lua @@ -52,8 +52,8 @@ local function run(...) loadFn = loadfile end - local bill, err = loadFn(path, env) - if not bill then + local funkshun, err = loadFn(path, env) + if not funkshun then error(err, -1) end @@ -68,7 +68,7 @@ local function run(...) } env[ "arg" ] = { [0] = path, table.unpack(args) } - local r = { bill(table.unpack(args)) } + local r = { funkshun(table.unpack(args)) } tProgramStack[#tProgramStack] = nil @@ -659,7 +659,7 @@ local function shellRead(history) return entry.value or '' end -local history = History.load('usr/.shell_history', 25) +local history = History.load('usr/.shell_history', 100) term.setBackgroundColor(_colors.backgroundColor) --term.clear() diff --git a/sys/init/2.vfs.lua b/sys/init/2.vfs.lua index b0e2ea7..e2406dc 100644 --- a/sys/init/2.vfs.lua +++ b/sys/init/2.vfs.lua @@ -100,26 +100,6 @@ end function nativefs.delete(node, dir) if node.mountPoint == dir then fs.unmount(dir) - -- hack here - -- if a file is mounted over an existing directory - -- ie. sys/apps/MOUNT.LUA - -- then sys and sys/apps are created as temp nodes - -- therefore, trying to delete sys was only - -- removing the node and not deleting the directory - -- Need a better way to backfill nodes in a way - -- that preserves the vfs functionality - - -- perhaps a flag that denotes that this - -- file/directory is the actual mount - - -- this hack will not fix - -- rm packages/common - -- where packages is linked from a drive - -- and urls are mounted under packages/common - -- (as the fstype will be linkfs) - if node.fstype == 'nativefs' then - fs.native.delete(dir) - end else fs.native.delete(dir) end @@ -316,11 +296,6 @@ function fs.mount(path, fstype, ...) end if not tp.nodes[d] then tp.nodes[d] = Util.shallowCopy(tp) - - if tp.nodes[d].source then - tp.nodes[d].source = fs.combine(tp.nodes[d].source, d) - end - tp.nodes[d].nodes = { } tp.nodes[d].mountPoint = fs.combine(tp.mountPoint, d) end diff --git a/sys/init/3.sys.lua b/sys/init/3.sys.lua index 7e18d18..ace7684 100644 --- a/sys/init/3.sys.lua +++ b/sys/init/3.sys.lua @@ -1,3 +1,42 @@ -local fs = _G.fs +local fs = _G.fs +local os = _G.os fs.loadTab('sys/etc/fstab') + +-- add some Lua compatibility functions +function os.remove(a) + if fs.exists(a) then + local s = pcall(fs.delete, a) + return s and true or nil, a .. ': Unable to remove file' + end + return nil, a .. ': No such file or directory' +end + +os.execute = function(cmd) + if not cmd then + return 1 + end + + local env = _G.getfenv(2) + local s, m = env.shell.run('sys/apps/shell.lua ' .. cmd) + + if not s then + return 1, m + end + + return 0 +end + +os.tmpname = function() + local fname + repeat + fname = 'tmp/a' .. math.random(1, 32768) + until not fs.exists(fname) + + return fname +end + +-- non-standard - will raise error instead +os.exit = function(code) + error('Terminated with ' .. code) +end diff --git a/sys/init/7.multishell.lua b/sys/init/7.multishell.lua index 3930eae..e7bb1e2 100644 --- a/sys/init/7.multishell.lua +++ b/sys/init/7.multishell.lua @@ -144,6 +144,9 @@ function multishell.openTab(env, tab) end end end + if tab.chainExit then + tab.chainExit(self, result, err, stack) + end end local routine, message = kernel.run(env, tab) diff --git a/sys/modules/opus/fs/linkfs.lua b/sys/modules/opus/fs/linkfs.lua index 8ffdb4c..813ce5f 100644 --- a/sys/modules/opus/fs/linkfs.lua +++ b/sys/modules/opus/fs/linkfs.lua @@ -5,7 +5,7 @@ local linkfs = { } -- TODO: implement broken links local methods = { 'exists', 'getFreeSpace', 'getSize', 'attributes', - 'isDir', 'isReadOnly', 'list', 'listEx', 'makeDir', 'open', 'getDrive' } + 'isDir', 'isReadOnly', 'list', 'makeDir', 'open', 'getDrive' } for _,m in pairs(methods) do linkfs[m] = function(node, dir, ...) @@ -18,7 +18,7 @@ function linkfs.resolve(node, dir) return dir:gsub(node.mountPoint, node.source, 1) end -function linkfs.mount(_, source) +function linkfs.mount(path, source) if not source then error('Source is required') end @@ -26,6 +26,9 @@ function linkfs.mount(_, source) if not fs.exists(source) then error('Source is missing') end + if path == source then + return + end if fs.isDir(source) then return { source = source, diff --git a/sys/modules/opus/fs/urlfs.lua b/sys/modules/opus/fs/urlfs.lua index 96b7854..b2c47ca 100644 --- a/sys/modules/opus/fs/urlfs.lua +++ b/sys/modules/opus/fs/urlfs.lua @@ -5,15 +5,19 @@ local fs = _G.fs local urlfs = { } -function urlfs.mount(_, url) +function urlfs.mount(path, url, force) if not url then error('URL is required') end - return { - url = url, - created = os.epoch('utc'), - modification = os.epoch('utc'), - } + + -- only mount if the file does not exist already + if not fs.exists(path) or force then + return { + url = url, + created = os.epoch('utc'), + modification = os.epoch('utc'), + } + end end function urlfs.attributes(node) @@ -38,7 +42,7 @@ function urlfs.getSize(node) end function urlfs.isReadOnly() - return true + return false end function urlfs.isDir() diff --git a/sys/modules/opus/injector.lua b/sys/modules/opus/injector.lua index aea109a..17a17f1 100644 --- a/sys/modules/opus/injector.lua +++ b/sys/modules/opus/injector.lua @@ -89,6 +89,7 @@ return function(env) os = os, string = string, table = table, + debug = debug, }, loaders = { preloadSearcher,