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.
This commit is contained in:
Tim Ledbetter 2023-06-20 18:06:51 +01:00 committed by Andreas Kling
parent c723101728
commit ba34931620

View file

@ -139,8 +139,14 @@ ErrorOr<int> 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;
}