v1.4.0 - Added better path handling to the filesystem library, cleaned up mv, cp, cd, cat and their help files.

This commit is contained in:
TheWahlolly
2025-05-22 21:00:38 +03:00
parent f52d0f7015
commit 500419de59
12 changed files with 95 additions and 86 deletions
+7 -22
View File
@@ -1,29 +1,14 @@
local args = {...}
local directory = args[1]
args = nil
local directory = ...
local fs = import("filesystem")
if not directory then
return
end
if directory == ".." then
local backDirectory = shell.workingDirectory:match("(.+)/.-/")
if backDirectory then
backDirectory = backDirectory .. "/"
else
backDirectory = "/"
end
shell.workingDirectory = backDirectory
if directory:sub(1, 1) ~= "/" then
directory = fs.concat(shell.workingDirectory, directory)
end
if fs.exists(directory) and fs.isDirectory(directory) then
shell.workingDirectory = fs.canonical(directory)
else
if directory:sub(-1, -1) ~= "/" then
directory = directory .. "/"
end
if directory:sub(1, 1) ~= "/" then
directory = shell.workingDirectory .. directory
end
if fs.exists(directory) and fs.isDirectory(directory) or fs.exists(shell.workingDirectory .. directory) and fs.isDirectory(shell.workingDirectory .. directory) then
shell.workingDirectory = directory
else
print("\27[91mNo such directory.")
end
print("\27[91mNo such directory.")
end