mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +00:00
realpath: Add the -q
option to suppress error messages
This commit is contained in:
parent
cbda6e1ff4
commit
e904f69c26
1 changed files with 5 additions and 1 deletions
|
@ -14,11 +14,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
TRY(Core::System::pledge("stdio rpath"));
|
TRY(Core::System::pledge("stdio rpath"));
|
||||||
|
|
||||||
|
bool quiet { false };
|
||||||
Vector<StringView> paths;
|
Vector<StringView> paths;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help(
|
args_parser.set_general_help(
|
||||||
"Show the 'real' path of a file, by resolving all symbolic links along the way.");
|
"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.add_positional_argument(paths, "Path to resolve", "paths");
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
|
@ -26,7 +28,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
auto resolved_path_or_error = FileSystem::real_path(path);
|
auto resolved_path_or_error = FileSystem::real_path(path);
|
||||||
if (resolved_path_or_error.is_error()) {
|
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;
|
has_errors = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue