|
@@ -6,6 +6,8 @@
|
|
|
|
|
|
#include <AK/Vector.h>
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
+#include <LibCore/System.h>
|
|
|
+#include <LibMain/Main.h>
|
|
|
#include <errno.h>
|
|
|
#include <fcntl.h>
|
|
|
#include <stdio.h>
|
|
@@ -13,19 +15,16 @@
|
|
|
#include <string.h>
|
|
|
#include <unistd.h>
|
|
|
|
|
|
-int main(int argc, char** argv)
|
|
|
+ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
{
|
|
|
- if (pledge("stdio rpath", nullptr) < 0) {
|
|
|
- perror("pledge");
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ TRY(Core::System::pledge("stdio rpath", nullptr));
|
|
|
|
|
|
Vector<String> paths;
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
|
|
args_parser.set_general_help("Concatenate files or pipes to stdout.");
|
|
|
args_parser.add_positional_argument(paths, "File path", "path", Core::ArgsParser::Required::No);
|
|
|
- args_parser.parse(argc, argv);
|
|
|
+ args_parser.parse(arguments);
|
|
|
|
|
|
Vector<int> fds;
|
|
|
if (!paths.is_empty()) {
|
|
@@ -43,10 +42,7 @@ int main(int argc, char** argv)
|
|
|
fds.append(0);
|
|
|
}
|
|
|
|
|
|
- if (pledge("stdio", nullptr) < 0) {
|
|
|
- perror("pledge");
|
|
|
- return 1;
|
|
|
- }
|
|
|
+ TRY(Core::System::pledge("stdio", nullptr));
|
|
|
|
|
|
for (auto& fd : fds) {
|
|
|
for (;;) {
|