--:Minify:-- syscall.open("/dev/tty/TTY1","r") syscall.open("/dev/tty/TTY1","w") syscall.open("/dev/null","r") syscall.devctl(1,"clear") syscall.devctl(1,"sfgc",1) syscall.devctl(1,"spos",1,1) print("HyperionOS Bash Shell") local str="" local stopInput=false local proc=0 local fs=require("sys.fs") local timeout=false syscall.setEnviron("SHELL","simpleshell") printInline("> ") syscall.sigcatch(function(sig) if sig==1 then syscall.kill(proc) print("Terminated") printInline("> ") stopInput=false end end) while true do if not stopInput then local input=syscall.read(0) if input then if input=="\b" then if #str>0 then str=str:sub(1,#str-1) printInline("\b") end elseif input=="\n" then print("") stopInput=true if str == "" then printInline("> ") stopInput=false else local path=nil local split=string.split(str, " ") if fs.exists("/bin/"..split[1]) then path="/bin/"..split[1] elseif fs.exists("/bin/"..split[1]..".lua") then path="/bin/"..split[1]..".lua" end if not path then print("Program not found") printInline("> ") stopInput=false else local text = fs.readAllText(path) local program, err = load(text, path) if not program then print(err) printInline("> ") end proc = syscall.spawn(function(...) syscall.open("/dev/tty/TTY1","r") syscall.open("/dev/tty/TTY1","w") syscall.open("/dev/null","w") program(...) end, path, nil, {table.unpack(split, 2)}) end str="" end else str=str..input printInline(input) end timeout=false else timeout=true end else local exited, code = syscall.collect(proc) if exited then if code then print("\nTask exited with code:\n"..tostring(code)) end printInline("> ") stopInput=false end timeout=true end if timeout then if stopInput then sleep(.5) else sleep(.05) end end end