From e904f69c26f998ae66cb25d203ba4027d9237b33 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 30 Sep 2023 15:20:55 +0100 Subject: [PATCH] realpath: Add the `-q` option to suppress error messages --- Userland/Utilities/realpath.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Utilities/realpath.cpp b/Userland/Utilities/realpath.cpp index c396da8905..24e3cd78c6 100644 --- a/Userland/Utilities/realpath.cpp +++ b/Userland/Utilities/realpath.cpp @@ -14,11 +14,13 @@ ErrorOr serenity_main(Main::Arguments arguments) { TRY(Core::System::pledge("stdio rpath")); + bool quiet { false }; Vector paths; Core::ArgsParser args_parser; args_parser.set_general_help( "Show the 'real' path of a file, by resolving all symbolic links along the way."); + args_parser.add_option(quiet, "Suppress error messages", "quiet", 'q'); args_parser.add_positional_argument(paths, "Path to resolve", "paths"); args_parser.parse(arguments); @@ -26,7 +28,9 @@ ErrorOr serenity_main(Main::Arguments arguments) for (auto path : paths) { auto resolved_path_or_error = FileSystem::real_path(path); if (resolved_path_or_error.is_error()) { - warnln("realpath: {}: {}", path, strerror(resolved_path_or_error.error().code())); + if (!quiet) + warnln("realpath: {}: {}", path, strerror(resolved_path_or_error.error().code())); + has_errors = true; continue; }