summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-01-14 10:25:11 +0100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-14 19:42:19 +0200
commit02cb34a48a7699344a0348c6dca8a814794f8bc4 (patch)
treecf5af3b971298296d71431fe889bedd5fb4432e9
parent5ac52d0e4c2542fbb9fd433144bbd68d9737d6f5 (diff)
downloadserenity-02cb34a48a7699344a0348c6dca8a814794f8bc4.zip
head: Port to LibMain
-rw-r--r--Userland/Utilities/CMakeLists.txt1
-rw-r--r--Userland/Utilities/head.cpp11
2 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt
index cd35adeb08..85ad8e0d90 100644
--- a/Userland/Utilities/CMakeLists.txt
+++ b/Userland/Utilities/CMakeLists.txt
@@ -105,6 +105,7 @@ target_link_libraries(gron LibMain)
target_link_libraries(groups LibMain)
target_link_libraries(gunzip LibCompress LibMain)
target_link_libraries(gzip LibCompress LibMain)
+target_link_libraries(head LibMain)
target_link_libraries(id LibMain)
target_link_libraries(ini LibMain)
target_link_libraries(jp LibMain)
diff --git a/Userland/Utilities/head.cpp b/Userland/Utilities/head.cpp
index d9dc256534..a230652398 100644
--- a/Userland/Utilities/head.cpp
+++ b/Userland/Utilities/head.cpp
@@ -6,6 +6,8 @@
#include <AK/StdLibExtras.h>
#include <LibCore/ArgsParser.h>
+#include <LibCore/System.h>
+#include <LibMain/Main.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
@@ -14,12 +16,9 @@
int head(const String& filename, bool print_filename, ssize_t line_count, ssize_t byte_count);
-int main(int argc, char** argv)
+ErrorOr<int> serenity_main(Main::Arguments args)
{
- if (pledge("stdio rpath", nullptr) < 0) {
- perror("pledge");
- return 1;
- }
+ TRY(Core::System::pledge("stdio rpath", nullptr));
int line_count = -1;
int byte_count = -1;
@@ -34,7 +33,7 @@ int main(int argc, char** argv)
args_parser.add_option(never_print_filenames, "Never print filenames", "quiet", 'q');
args_parser.add_option(always_print_filenames, "Always print filenames", "verbose", 'v');
args_parser.add_positional_argument(files, "File to process", "file", Core::ArgsParser::Required::No);
- args_parser.parse(argc, argv);
+ args_parser.parse(args);
if (line_count == -1 && byte_count == -1) {
line_count = 10;