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