v0.8.1 - Fixed a couple bugs involving the shell crashing and fetch. Added proper shell error handling.

This commit is contained in:
TheWahlolly
2025-04-27 20:00:06 +03:00
parent 614c9011cf
commit f478048976
8 changed files with 37 additions and 4 deletions
+3
View File
@@ -3,6 +3,9 @@ local directory = args[1]
args = nil args = nil
local fs = import("filesystem") local fs = import("filesystem")
if not directory then
return
end
if directory == ".." then if directory == ".." then
local backDirectory = shell.workingDirectory:match("(.+)/.-/") local backDirectory = shell.workingDirectory:match("(.+)/.-/")
if backDirectory then if backDirectory then
+4
View File
@@ -3,6 +3,10 @@ local fromFile, toFile = args[1], args[2]
args = nil args = nil
local fs = import("filesystem") local fs = import("filesystem")
if not fromFile or not toFile then
shell.run("help cp")
return
end
if fromFile:sub(1, 1) ~= "/" then if fromFile:sub(1, 1) ~= "/" then
fromFile = shell.workingDirectory .. fromFile fromFile = shell.workingDirectory .. fromFile
end end
+2 -1
View File
@@ -1,4 +1,5 @@
termlib.cursorPosY = termlib.cursorPosY + 2 print("")
print("")
print(" \27[93m┌┬┐ ┌┐ ┌┐ \n ││├─┤├┬┬┘├─┐\n │┐├┘││││││││\n ││││││││││┌┤\n └┴┴─┴┼┐├─┴─┘\n └─┘ ") print(" \27[93m┌┬┐ ┌┐ ┌┐ \n ││├─┤├┬┬┘├─┐\n │┐├┘││││││││\n ││││││││││┌┤\n └┴┴─┴┼┐├─┴─┘\n └─┘ ")
termlib.cursorPosX, termlib.cursorPosY = 17, termlib.cursorPosY - 8 termlib.cursorPosX, termlib.cursorPosY = 17, termlib.cursorPosY - 8
print("\27[92mOS\27[0m: ".._OSVERSION) print("\27[92mOS\27[0m: ".._OSVERSION)
+4
View File
@@ -3,6 +3,10 @@ local fromFile, toFile = args[1], args[2]
args = nil args = nil
local fs = import("filesystem") local fs = import("filesystem")
if not fromFile or not toFile then
shell.run("help mv")
return
end
if fromFile:sub(1, 1) ~= "/" then if fromFile:sub(1, 1) ~= "/" then
fromFile = shell.workingDirectory .. fromFile fromFile = shell.workingDirectory .. fromFile
end end
+4
View File
@@ -3,6 +3,10 @@ local file = args[1]
args = nil args = nil
local fs = import("filesystem") local fs = import("filesystem")
if not file then
shell.run("help rm")
return
end
if file:sub(1, 1) ~= "/" then if file:sub(1, 1) ~= "/" then
file = shell.workingDirectory .. file file = shell.workingDirectory .. file
end end
+1 -1
View File
@@ -1,7 +1,7 @@
local loadfile = ... local loadfile = ...
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
_G._OSVERSION = "Halyde 0.8.0" _G._OSVERSION = "Halyde 0.8.1"
function _G.import(module, ...) function _G.import(module, ...)
local args = table.pack(...) local args = table.pack(...)
+11
View File
@@ -41,6 +41,9 @@ function _G.shell.run(command)
end end
-- execute the program -- execute the program
local foundfile = false local foundfile = false
if not args[1] then
return
end
if filesystem.exists(args[1]) then if filesystem.exists(args[1]) then
foundfile = true foundfile = true
local path = args[1] local path = args[1]
@@ -60,7 +63,15 @@ function _G.shell.run(command)
if args[1] == file:match("(.+)%.[^%.]+$") then if args[1] == file:match("(.+)%.[^%.]+$") then
foundfile = true foundfile = true
table.remove(args, 1) table.remove(args, 1)
local function runCommand()
import(item..file, table.unpack(args)) import(item..file, table.unpack(args))
end
local result, reason = xpcall(runCommand, function(errMsg)
return errMsg .. "\n\n" .. debug.traceback()
end)
if not result then
print("\27[91m" .. reason)
end
break break
end end
end end
+7 -1
View File
@@ -41,7 +41,13 @@ gpu.setBackground(defaultBackgroundColor)
local function scrollDown() local function scrollDown()
if gpu.copy(0,1,width,height,0,-1) then if gpu.copy(0,1,width,height,0,-1) then
gpu.set(1,height,string.rep(" ",width)) local prevForeground = gpu.getForeground()
local prevBackground = gpu.getBackground()
gpu.setForeground(defaultForegroundColor)
gpu.setBackground(defaultBackgroundColor)
gpu.fill(1, height, width, 1, " ")
gpu.setForeground(prevForeground)
gpu.setBackground(prevBackground)
termlib.cursorPosY=height termlib.cursorPosY=height
end end
end end