diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index f293faab72..5af8531716 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -64,6 +64,7 @@ target_link_libraries(chres LibGUI) target_link_libraries(cksum LibCrypto) target_link_libraries(config LibConfig) target_link_libraries(copy LibGUI LibMain) +target_link_libraries(cp LibMain) target_link_libraries(diff LibDiff) target_link_libraries(disasm LibX86) target_link_libraries(dmesg LibMain) diff --git a/Userland/Utilities/cp.cpp b/Userland/Utilities/cp.cpp index d6d1fb4599..4c1d4ecc96 100644 --- a/Userland/Utilities/cp.cpp +++ b/Userland/Utilities/cp.cpp @@ -7,15 +7,14 @@ #include #include #include +#include +#include #include #include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath wpath cpath fattr chown", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio rpath wpath cpath fattr chown", nullptr)); bool link = false; bool preserve = false; @@ -32,15 +31,12 @@ int main(int argc, char** argv) args_parser.add_option(verbose, "Verbose", "verbose", 'v'); args_parser.add_positional_argument(sources, "Source file paths", "source"); args_parser.add_positional_argument(destination, "Destination file path", "destination"); - args_parser.parse(argc, argv); + args_parser.parse(arguments); if (preserve) { umask(0); } else { - if (pledge("stdio rpath wpath cpath fattr", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio rpath wpath cpath fattr", nullptr)); } bool destination_is_existing_dir = Core::File::is_directory(destination);