summaryrefslogtreecommitdiff
path: root/Userland/Utilities/ls.cpp
diff options
context:
space:
mode:
authorsetepenre <usermaatre.setepenre@protonmail.com>2021-04-11 16:48:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-11 18:16:46 +0200
commitfe8cefa7c1b056bb4097c4dce27a0304295d8429 (patch)
treebc41f3b3e46a37fc4a1332059b5caaefc40b32c8 /Userland/Utilities/ls.cpp
parent433a23cfdeda1ae3f2f8ee14ed841a6e7716381b (diff)
downloadserenity-fe8cefa7c1b056bb4097c4dce27a0304295d8429.zip
ls: ls will print directory name when listing multiple directories
Diffstat (limited to 'Userland/Utilities/ls.cpp')
-rw-r--r--Userland/Utilities/ls.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp
index 7dffbe405d..5f30c71db2 100644
--- a/Userland/Utilities/ls.cpp
+++ b/Userland/Utilities/ls.cpp
@@ -145,8 +145,22 @@ int main(int argc, char** argv)
} else if (paths.size() == 1) {
status = do_file_system_object(paths[0]);
} else {
+ Vector<const char*> exists;
for (auto& path : paths) {
+ if (Core::File::exists(path)) {
+ exists.append(path);
+ } else {
+ status = do_file_system_object(path);
+ }
+ }
+ for (size_t i = 0; i < exists.size(); ++i) {
+ auto path = exists.at(i);
+ printf("%s:\n", path);
status = do_file_system_object(path);
+
+ if (i + 1 == exists.size() - 1) {
+ printf("\n");
+ }
}
}
return status;