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