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>
|
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
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
|
{
|
2020-02-18 10:58:56 +01:00
|
|
|
if (pledge("stdio rpath", nullptr) < 0) {
|
|
|
|
|
perror("pledge");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-05 19:39:42 +02:00
|
|
|
const char* 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");
|
|
|
|
|
args_parser.parse(argc, argv);
|
2019-08-28 23:23:23 -05:00
|
|
|
|
2020-09-16 19:10:32 +02:00
|
|
|
auto fullpath = Core::find_executable_in_path(filename);
|
|
|
|
|
if (fullpath.is_null()) {
|
|
|
|
|
printf("no '%s' in path\n", filename);
|
|
|
|
|
return 1;
|
2019-08-28 23:23:23 -05:00
|
|
|
}
|
|
|
|
|
|
2020-09-16 19:10:32 +02:00
|
|
|
printf("%s\n", fullpath.characters());
|
|
|
|
|
return 0;
|
2019-08-28 23:23:23 -05:00
|
|
|
}
|