added getuid and made more docs and working on half functional lua
This commit is contained in:
48
Src/Hyperion-bash/bin/lua
Normal file
48
Src/Hyperion-bash/bin/lua
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
--:Minify:--
|
||||||
|
syscall.TTY_print("HyperionOS lua")
|
||||||
|
local str=""
|
||||||
|
local stopInput=false
|
||||||
|
local timeout=false
|
||||||
|
local luaEnv=setmetatable({},{__index=_ENV})
|
||||||
|
printInline("> ")
|
||||||
|
while true do
|
||||||
|
local event = {syscall.IO_pullEvent()}
|
||||||
|
if event[1] then
|
||||||
|
if not stopInput then
|
||||||
|
if event[1]=="keyTyped" then
|
||||||
|
if event[3]=="\b" then
|
||||||
|
if #str>0 then
|
||||||
|
str=str:sub(1,#str-1)
|
||||||
|
printInline("\b")
|
||||||
|
end
|
||||||
|
elseif event[3]=="\n" then
|
||||||
|
print("")
|
||||||
|
stopInput=true
|
||||||
|
if str == "" then
|
||||||
|
printInline("> ")
|
||||||
|
stopInput=false
|
||||||
|
elseif str == "exit" then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
local func=load(str,"@Lua","t",luaEnv)
|
||||||
|
local ok,err = xpcall(func, debug.traceback)
|
||||||
|
if not ok then
|
||||||
|
print(err)
|
||||||
|
end
|
||||||
|
stopInput=false
|
||||||
|
str=""
|
||||||
|
end
|
||||||
|
else
|
||||||
|
str=str..event[3]
|
||||||
|
printInline(event[3])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
timeout=false
|
||||||
|
else
|
||||||
|
timeout=true
|
||||||
|
end
|
||||||
|
if timeout then
|
||||||
|
sleep(.05)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -241,7 +241,7 @@ kernel.syscalls["getHostname"]=function() return kernel.host end
|
|||||||
kernel.syscalls["getHost"]=function() return kernel.apis._HOST end
|
kernel.syscalls["getHost"]=function() return kernel.apis._HOST end
|
||||||
kernel.syscalls["version"]=function() return kernel.version end
|
kernel.syscalls["version"]=function() return kernel.version end
|
||||||
kernel.syscalls["setHostname"]=function(name) if kernel.uid~=0 then error("Permission denied") end kernel.hostname=name end
|
kernel.syscalls["setHostname"]=function(name) if kernel.uid~=0 then error("Permission denied") end kernel.hostname=name end
|
||||||
kernel.syscalls["setUser"]=function(uid) if kernel.uid~=0 then error("Permission denied") end kernel.currentTask.uid=uid end
|
kernel.syscalls["setUser"]=function(user) if kernel.uid~=0 then error("Permission denied") end kernel.currentTask.user=user end
|
||||||
kernel.syscalls["test"]=function() return true end
|
kernel.syscalls["test"]=function() return true end
|
||||||
|
|
||||||
kernel.log("Running modules")
|
kernel.log("Running modules")
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ function sys.setuid(uid)
|
|||||||
kernel.currentTask.uid=uid
|
kernel.currentTask.uid=uid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function sys.getuid()
|
||||||
|
return kernel.currentTask.uid
|
||||||
|
end
|
||||||
|
|
||||||
local sysc=kernel.syscalls
|
local sysc=kernel.syscalls
|
||||||
sysc["spawn"]=sys.spawn
|
sysc["spawn"]=sys.spawn
|
||||||
sysc["sleep"]=sys.sleep
|
sysc["sleep"]=sys.sleep
|
||||||
@@ -227,6 +231,7 @@ sysc["setEnviron"]=sys.setEnviron
|
|||||||
sysc["getEnviron"]=sys.getEnviron
|
sysc["getEnviron"]=sys.getEnviron
|
||||||
sysc["exit"]=sys.exit
|
sysc["exit"]=sys.exit
|
||||||
sysc["setuid"]=sys.setuid
|
sysc["setuid"]=sys.setuid
|
||||||
|
sysc["getuid"]=sys.getuid
|
||||||
kernel._G.sleep=function(...)coroutine.yield("syscall","sleep",...)end
|
kernel._G.sleep=function(...)coroutine.yield("syscall","sleep",...)end
|
||||||
|
|
||||||
local function reapDeadTasks()
|
local function reapDeadTasks()
|
||||||
|
|||||||
@@ -28,5 +28,5 @@ logTaskExit<bool>
|
|||||||
logs task exits and errors
|
logs task exits and errors
|
||||||
|
|
||||||
showModLoad<bool>
|
showModLoad<bool>
|
||||||
log mofule loads
|
log module loads
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user