Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <LibCore/ArgsParser.h>
8#include <LibCore/DeprecatedFile.h>
9#include <LibCore/System.h>
10#include <stdio.h>
11#include <unistd.h>
12
13ErrorOr<int> serenity_main(Main::Arguments arguments)
14{
15 TRY(Core::System::pledge("stdio rpath"));
16
17 StringView filename;
18
19 Core::ArgsParser args_parser;
20 args_parser.add_positional_argument(filename, "Name of executable", "executable");
21 args_parser.parse(arguments);
22
23 auto fullpath = Core::DeprecatedFile::resolve_executable_from_environment(filename);
24 if (!fullpath.has_value()) {
25 warnln("no '{}' in path", filename);
26 return 1;
27 }
28
29 outln("{}", fullpath.release_value());
30 return 0;
31}