2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2020-08-05 20:39:42 +03:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2023-02-08 23:08:01 +03:00
|
|
|
#include <LibCore/DeprecatedFile.h>
|
2022-01-04 08:03:19 +03:00
|
|
|
#include <LibCore/System.h>
|
2019-08-29 07:23:23 +03:00
|
|
|
#include <stdio.h>
|
2021-03-12 19:29:37 +03:00
|
|
|
#include <unistd.h>
|
2019-08-29 07:23:23 +03:00
|
|
|
|
2022-01-04 08:03:19 +03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2019-08-29 07:23:23 +03:00
|
|
|
{
|
2022-01-04 08:03:19 +03:00
|
|
|
TRY(Core::System::pledge("stdio rpath"));
|
2020-02-18 12:58:56 +03:00
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
char const* filename = nullptr;
|
2019-08-29 07:23:23 +03:00
|
|
|
|
2020-08-05 20:39:42 +03:00
|
|
|
Core::ArgsParser args_parser;
|
|
|
|
args_parser.add_positional_argument(filename, "Name of executable", "executable");
|
2022-01-04 08:03:19 +03:00
|
|
|
args_parser.parse(arguments);
|
2019-08-29 07:23:23 +03:00
|
|
|
|
2023-02-08 23:08:01 +03:00
|
|
|
auto fullpath = Core::DeprecatedFile::resolve_executable_from_environment({ filename, strlen(filename) });
|
2022-08-20 19:31:03 +03:00
|
|
|
if (!fullpath.has_value()) {
|
2021-05-30 16:06:19 +03:00
|
|
|
warnln("no '{}' in path", filename);
|
2020-09-16 20:10:32 +03:00
|
|
|
return 1;
|
2019-08-29 07:23:23 +03:00
|
|
|
}
|
|
|
|
|
2022-08-20 19:31:03 +03:00
|
|
|
outln("{}", fullpath.release_value());
|
2020-09-16 20:10:32 +03:00
|
|
|
return 0;
|
2019-08-29 07:23:23 +03:00
|
|
|
}
|