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:
+7
-22
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user