From b4e125cf86b2dcb37e8d32eb927a595aa0e009a5 Mon Sep 17 00:00:00 2001 From: Sahan Fernando Date: Tue, 12 Jan 2021 14:13:07 +1100 Subject: [PATCH] Userland: Make rmdir take multiple paths --- Userland/Utilities/rmdir.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Userland/Utilities/rmdir.cpp b/Userland/Utilities/rmdir.cpp index 9a5f6df12a..7aa55f3bad 100644 --- a/Userland/Utilities/rmdir.cpp +++ b/Userland/Utilities/rmdir.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include @@ -16,16 +17,19 @@ int main(int argc, char** argv) return 1; } - const char* path; + Vector paths; Core::ArgsParser args_parser; - args_parser.add_positional_argument(path, "Directory to remove", "path"); + args_parser.add_positional_argument(paths, "Directories to remove", "paths"); args_parser.parse(argc, argv); - int rc = rmdir(path); - if (rc < 0) { - perror("rmdir"); - return 1; + int status = 0; + for (auto path : paths) { + int rc = rmdir(path); + if (rc < 0) { + perror("rmdir"); + status = 1; + } } - return 0; + return status; }