summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-02 22:42:10 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-04 14:24:04 +0100
commit0de575ec11cd059663b10e11eca0b4282e0ca0de (patch)
tree77b341aa852aa6aa3bdd1a184063e6dedae81a5b /Userland/Utilities
parent1640445cb2f5027eebbce90faf5273cff85ed844 (diff)
downloadserenity-0de575ec11cd059663b10e11eca0b4282e0ca0de.zip
ls: Port to LibMain :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/CMakeLists.txt1
-rw-r--r--Userland/Utilities/ls.cpp11
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt
index 2027c6a5ec..68ef420ce6 100644
--- a/Userland/Utilities/CMakeLists.txt
+++ b/Userland/Utilities/CMakeLists.txt
@@ -85,6 +85,7 @@ target_link_libraries(id LibMain)
target_link_libraries(js LibJS LibLine LibMain)
target_link_libraries(keymap LibKeyboard LibMain)
target_link_libraries(logout LibMain)
+target_link_libraries(ls LibMain)
target_link_libraries(lspci LibPCIDB LibMain)
target_link_libraries(lsusb LibUSBDB LibMain)
target_link_libraries(man LibMarkdown LibMain)
diff --git a/Userland/Utilities/ls.cpp b/Userland/Utilities/ls.cpp
index 39614ed889..51f90d905d 100644
--- a/Userland/Utilities/ls.cpp
+++ b/Userland/Utilities/ls.cpp
@@ -17,6 +17,8 @@
#include <LibCore/DateTime.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
+#include <LibCore/System.h>
+#include <LibMain/Main.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
@@ -71,12 +73,9 @@ static HashMap<gid_t, String> groups;
static bool is_a_tty = false;
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments arguments)
{
- if (pledge("stdio rpath tty", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio rpath tty"));
struct winsize ws;
int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
@@ -118,7 +117,7 @@ int main(int argc, char** argv)
args_parser.add_option(flag_disable_hyperlinks, "Disable hyperlinks", "no-hyperlinks", 'K');
args_parser.add_option(flag_recursive, "List subdirectories recursively", "recursive", 'R');
args_parser.add_positional_argument(paths, "Directory to list", "path", Core::ArgsParser::Required::No);
- args_parser.parse(argc, argv);
+ args_parser.parse(arguments);
if (flag_show_almost_all_dotfiles)
flag_show_dotfiles = true;