This commit is contained in:
2026-08-23 21:17:51 +02:00
parent 7807cf430c
commit 1a422196eb
8 changed files with 104 additions and 94 deletions

View File

@@ -1,6 +1,6 @@
if params.len > 0 and (params[0] == "-h" or params[0] == "--help") then
current_program = get_shell.host_computer.File(program_path)
print("Usage: " + current_program.name + " [path...]")
print "Usage: " + current_program.name + " [path...]"
exit
end if
@@ -9,25 +9,25 @@ computer = get_shell.host_computer
entry_line = function(f, display_name)
name = display_name
if f.is_folder then
name = name + "/"
name += "/"
else if f.permissions.indexOf("x") != null then
name = name + "*"
name += "*"
end if
return f.permissions + " " + f.owner + " " + f.group + " " + f.size + " " + name
end function
list_path = function(target, raw_path)
if not target then
print(raw_path + ": No such file or directory")
return
print raw_path + ": No such file or directory"
return
end if
if not target.is_folder then
print(format_columns(entry_line(target, target.name)))
return
print format_columns(entry_line(target, target.name))
return
end if
if not target.has_permission("r") then
print(raw_path + ": Permission denied")
return
print raw_path + ": Permission denied"
return
end if
lines = entry_line(target, ".")
parent = target.parent
@@ -40,21 +40,27 @@ list_path = function(target, raw_path)
if not files then files = []
named = []
for f in folders
named.push({"name": f.name, "entry": f})
named.push {
"name": f.name,
"entry": f,
}
end for
named.sort("name")
named.sort "name"
for item in named
lines = lines + "\n" + entry_line(item.entry, item.name)
end for
named = []
for f in files
named.push({"name": f.name, "entry": f})
named.push {
"name": f.name,
"entry": f,
}
end for
named.sort("name")
named.sort "name"
for item in named
lines = lines + "\n" + entry_line(item.entry, item.name)
end for
print(format_columns(lines))
print format_columns(lines)
end function
resolve = function(p)
@@ -67,13 +73,13 @@ resolve = function(p)
end function
if params.len < 1 then
list_path(computer.File(current_path), current_path)
list_path computer.File(current_path), current_path
else
i = 0
for p in params
if i > 0 then print("")
if params.len > 1 then print(p + ":")
list_path(resolve(p), p)
i = i + 1
list_path resolve(p), p
i += 1
end for
end if