diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-07-25 16:54:52 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-07-25 23:52:46 +0100 |
commit | 7b7c9a21946fd9ffd5c0868b66e238b4b7f84c0c (patch) | |
tree | 1185705ec3c43e779e3974995bbafbf1f0b9bb55 | |
parent | bd48d9521a4c60ffa1a6e7b0a8bc6b14e1b063ec (diff) | |
download | serenity-7b7c9a21946fd9ffd5c0868b66e238b4b7f84c0c.zip |
chown: Add support for multiple file paths
-rw-r--r-- | Userland/Utilities/chown.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Utilities/chown.cpp b/Userland/Utilities/chown.cpp index d215577a9a..c0173d042e 100644 --- a/Userland/Utilities/chown.cpp +++ b/Userland/Utilities/chown.cpp @@ -21,14 +21,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath chown")); String spec; - String path; + Vector<StringView> paths; bool dont_follow_symlinks = false; Core::ArgsParser args_parser; args_parser.set_general_help("Change the ownership of a file or directory."); args_parser.add_option(dont_follow_symlinks, "Don't follow symlinks", "no-dereference", 'h'); args_parser.add_positional_argument(spec, "User and group IDs", "USER[:GROUP]"); - args_parser.add_positional_argument(path, "Path to file", "PATH"); + args_parser.add_positional_argument(paths, "Paths to files", "PATH"); args_parser.parse(arguments); uid_t new_uid = -1; @@ -66,10 +66,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) } } - if (dont_follow_symlinks) { - TRY(Core::System::lchown(path, new_uid, new_gid)); - } else { - TRY(Core::System::chown(path, new_uid, new_gid)); + for (auto path : paths) { + if (dont_follow_symlinks) { + TRY(Core::System::lchown(path, new_uid, new_gid)); + } else { + TRY(Core::System::chown(path, new_uid, new_gid)); + } } return 0; |