mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
Userland: Consolidate most PATH resolving into a single implementation
We previously had at least three different implementations for resolving executables in the PATH, all of which had slightly different characteristics. Merge those into a single implementation to keep the behaviour consistent, and maybe to make that implementation more configurable in the future.
This commit is contained in:
parent
39a3775f48
commit
5f99934dce
13 changed files with 74 additions and 95 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -20,12 +20,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(filename, "Name of executable", "executable");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
auto fullpath = Core::find_executable_in_path(filename);
|
||||
if (fullpath.is_empty()) {
|
||||
auto fullpath = Core::File::resolve_executable_from_environment({ filename, strlen(filename) });
|
||||
if (!fullpath.has_value()) {
|
||||
warnln("no '{}' in path", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
outln("{}", fullpath);
|
||||
outln("{}", fullpath.release_value());
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue