diff options
Diffstat (limited to 'Userland/Utilities/chgrp.cpp')
-rw-r--r-- | Userland/Utilities/chgrp.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/Userland/Utilities/chgrp.cpp b/Userland/Utilities/chgrp.cpp index 69aba6b9fb..580febb215 100644 --- a/Userland/Utilities/chgrp.cpp +++ b/Userland/Utilities/chgrp.cpp @@ -6,17 +6,14 @@ #include <AK/String.h> #include <LibCore/ArgsParser.h> +#include <LibCore/System.h> +#include <LibMain/Main.h> #include <grp.h> -#include <stdio.h> #include <string.h> -#include <unistd.h> -int main(int argc, char** argv) +ErrorOr<int> serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath chown", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio rpath chown", nullptr)); const char* gid_arg = nullptr; const char* path = nullptr; @@ -25,7 +22,7 @@ int main(int argc, char** argv) args_parser.set_general_help("Change the owning group for a file or directory."); args_parser.add_positional_argument(gid_arg, "Group ID", "gid"); args_parser.add_positional_argument(path, "Path to file", "path"); - args_parser.parse(argc, argv); + args_parser.parse(arguments); gid_t new_gid = -1; @@ -46,11 +43,7 @@ int main(int argc, char** argv) new_gid = group->gr_gid; } - int rc = chown(path, -1, new_gid); - if (rc < 0) { - perror("chgrp"); - return 1; - } + TRY(Core::System::chown(path, -1, new_gid)); return 0; } |