2020-06-16 19:03:19 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-16 19:03:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <LibCore/ArgsParser.h>
|
2022-03-23 16:12:49 +00:00
|
|
|
#include <LibCore/System.h>
|
2023-05-12 21:31:49 +00:00
|
|
|
#include <LibFileSystem/FileSystem.h>
|
2022-03-23 16:12:49 +00:00
|
|
|
#include <LibMain/Main.h>
|
2020-06-16 19:03:19 +00:00
|
|
|
|
2022-03-23 16:12:49 +00:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-06-16 19:03:19 +00:00
|
|
|
{
|
2022-03-23 16:12:49 +00:00
|
|
|
TRY(Core::System::pledge("stdio rpath"));
|
2020-06-16 19:03:19 +00:00
|
|
|
|
|
|
|
bool no_newline = false;
|
2022-03-23 16:13:11 +00:00
|
|
|
Vector<StringView> paths;
|
2020-06-16 19:03:19 +00:00
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
|
|
|
args_parser.add_option(no_newline, "Do not append a newline", "no-newline", 'n');
|
|
|
|
args_parser.add_positional_argument(paths, "Symlink path", "path");
|
2022-03-23 16:12:49 +00:00
|
|
|
args_parser.parse(arguments);
|
2020-06-16 19:03:19 +00:00
|
|
|
|
2022-03-23 16:13:11 +00:00
|
|
|
for (auto path : paths) {
|
2023-05-12 21:31:49 +00:00
|
|
|
auto destination = TRY(FileSystem::read_link(path));
|
2021-05-31 14:43:25 +00:00
|
|
|
out("{}", destination);
|
2020-06-16 19:03:19 +00:00
|
|
|
if (!no_newline)
|
2021-05-31 14:43:25 +00:00
|
|
|
outln();
|
2020-06-16 19:03:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|