From ba34931620deb806beaf23dbb7b57345c5d197ca Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 20 Jun 2023 18:06:51 +0100 Subject: [PATCH] strings: Don't bail immediately on error Previously, strings would exit immediately if there was an error changing file ownership. We now print an error to stderr and continue when an error occurs. --- Userland/Utilities/strings.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp index abcc46a75a..aa59f1fd58 100644 --- a/Userland/Utilities/strings.cpp +++ b/Userland/Utilities/strings.cpp @@ -139,8 +139,14 @@ ErrorOr serenity_main(Main::Arguments arguments) if (paths.is_empty()) paths.append("-"sv); - for (auto const& path : paths) - TRY(process_strings_in_file(path, show_paths, string_offset_format, minimum_string_length)); + bool has_errors = false; + for (auto const& path : paths) { + auto maybe_error = process_strings_in_file(path, show_paths, string_offset_format, minimum_string_length); + if (maybe_error.is_error()) { + warnln("strings: '{}'. {}", path, strerror(maybe_error.error().code())); + has_errors = true; + } + } - return 0; + return has_errors ? 1 : 0; }