From d7446e05dbb21613719d253f6e12e072497e425c Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 7 May 2021 14:35:23 +0100 Subject: [PATCH] file: Don't exit immediately after file open error Instead just remember that a file failed to open, carry on and return 1 at the end. --- Userland/Utilities/file.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index 7e53361767..caa9fc9d6b 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -81,11 +81,14 @@ int main(int argc, char** argv) args_parser.add_positional_argument(paths, "Files to identify", "files", Core::ArgsParser::Required::Yes); args_parser.parse(argc, argv); + bool all_ok = true; + for (auto path : paths) { auto file = Core::File::construct(path); if (!file->open(Core::File::ReadOnly)) { perror(path); - return 1; + all_ok = false; + continue; } auto bytes = file->read(25); auto file_name_guess = Core::guess_mime_type_based_on_filename(path); @@ -94,5 +97,5 @@ int main(int argc, char** argv) outln("{}: {}", path, flag_mime_only ? mime_type : human_readable_description); } - return 0; + return all_ok ? 0 : 1; }