2020-06-16 16:03:19 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Sergey Bugaev <bugaevc@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-16 16:03:19 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibCore/ArgsParser.h>
|
|
|
|
|
#include <LibCore/File.h>
|
2022-03-23 13:12:49 -03:00
|
|
|
#include <LibCore/System.h>
|
|
|
|
|
#include <LibMain/Main.h>
|
2020-06-16 16:03:19 -03:00
|
|
|
|
2022-03-23 13:12:49 -03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2020-06-16 16:03:19 -03:00
|
|
|
{
|
2022-03-23 13:12:49 -03:00
|
|
|
TRY(Core::System::pledge("stdio rpath"));
|
2020-06-16 16:03:19 -03:00
|
|
|
|
|
|
|
|
bool no_newline = false;
|
2022-03-23 13:13:11 -03:00
|
|
|
Vector<StringView> paths;
|
2020-06-16 16:03:19 -03: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 13:12:49 -03:00
|
|
|
args_parser.parse(arguments);
|
2020-06-16 16:03:19 -03:00
|
|
|
|
2022-03-23 13:13:11 -03:00
|
|
|
for (auto path : paths) {
|
2022-03-23 13:12:49 -03:00
|
|
|
auto destination = TRY(Core::File::read_link(path));
|
2021-05-31 11:43:25 -03:00
|
|
|
out("{}", destination);
|
2020-06-16 16:03:19 -03:00
|
|
|
if (!no_newline)
|
2021-05-31 11:43:25 -03:00
|
|
|
outln();
|
2020-06-16 16:03:19 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|