mirror of
https://github.com/kepler155c/opus
synced 2025-10-14 07:17:40 +00:00
update shell with require
This commit is contained in:
@@ -16,11 +16,21 @@ end
|
||||
-- 'usr gitfs kepler155c/opus-apps/' .. _G.OPUS_BRANCH)
|
||||
--end
|
||||
|
||||
local lua_path = '?;?.lua;?/init.lua'
|
||||
lua_path = lua_path .. ';/usr/apis/?;/usr/apis/?.lua'
|
||||
lua_path = lua_path .. ';/sys/apis/?;/sys/apis/?.lua'
|
||||
lua_path = lua_path .. ';/rom/modules/main/?;/rom/modules/main/?.lua;/rom/modules/main/?/init.lua;'
|
||||
if _G.turtle then
|
||||
lua_path = lua_path..';/rom/modules/turtle/?;/rom/modules/turtle/?.lua;/rom/modules/turtle/?/init.lua'
|
||||
elseif _G.command then
|
||||
lua_path = lua_path..';/rom/modules/command/?;/rom/modules/command/?.lua;/rom/modules/command/?/init.lua'
|
||||
end
|
||||
|
||||
if not fs.exists('usr/config/shell') then
|
||||
Util.writeTable('usr/config/shell', {
|
||||
aliases = shell.aliases(),
|
||||
path = 'usr/apps:sys/apps:' .. shell.path(),
|
||||
lua_path = 'sys/apis:usr/apis',
|
||||
lua_path = lua_path,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -45,6 +55,7 @@ if config.aliases then
|
||||
end
|
||||
end
|
||||
shell.setPath(config.path)
|
||||
_G.LUA_PATH = config.lua_path
|
||||
--_G.LUA_PATH = config.lua_path
|
||||
_G.LUA_PATH = lua_path
|
||||
|
||||
fs.loadTab('usr/config/fstab')
|
||||
|
@@ -6,20 +6,21 @@ local Util = require('util')
|
||||
local shell = _ENV.shell
|
||||
local fs = _G.fs
|
||||
|
||||
local appPaths = Util.split(shell.path(), '(.-):')
|
||||
local luaPaths = Util.split(_G.LUA_PATH, '(.-):')
|
||||
local appPaths = Util.split(shell.path(), '(.-);')
|
||||
local luaPaths = Util.split(_G.LUA_PATH, '(.-);')
|
||||
|
||||
local function addPath(t, e)
|
||||
local function hasEntry()
|
||||
local function addPath(t, path)
|
||||
local function addEntry(e)
|
||||
for _,v in ipairs(t) do
|
||||
if v == e then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if not hasEntry() then
|
||||
table.insert(t, 1, e)
|
||||
end
|
||||
addEntry(string.format('/%s/?', path))
|
||||
addEntry(string.format('/%s/?.lua', path))
|
||||
addEntry(string.format('/%s/?/init.lua', path))
|
||||
end
|
||||
|
||||
-- dependency graph
|
||||
@@ -42,4 +43,4 @@ for name in pairs(Packages:installed()) do
|
||||
end
|
||||
|
||||
shell.setPath(table.concat(appPaths, ':'))
|
||||
_G.LUA_PATH = table.concat(luaPaths, ':')
|
||||
_G.LUA_PATH = table.concat(luaPaths, ';')
|
||||
|
Reference in New Issue
Block a user