diff options
author | Tim Schumacher <timschumi@gmx.de> | 2022-08-20 18:31:03 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 19:00:04 +0100 |
commit | 5f99934dce1e00f5856bd40dca9d5e86e71d625e (patch) | |
tree | aaec591e2fd977714fa200a184c8b5ec701c73e9 /Userland/Shell/Builtin.cpp | |
parent | 39a3775f4870fb16b49fec24aa5fd506b17a0ea9 (diff) | |
download | serenity-5f99934dce1e00f5856bd40dca9d5e86e71d625e.zip |
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.
Diffstat (limited to 'Userland/Shell/Builtin.cpp')
-rw-r--r-- | Userland/Shell/Builtin.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index a0409ed3a2..caf9c8034b 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -232,9 +232,9 @@ int Shell::builtin_type(int argc, char const** argv) } // check if its an executable in PATH - auto fullpath = Core::find_executable_in_path(command); - if (!fullpath.is_empty()) { - printf("%s is %s\n", command.characters(), escape_token(fullpath).characters()); + auto fullpath = Core::File::resolve_executable_from_environment(command); + if (fullpath.has_value()) { + printf("%s is %s\n", command.characters(), escape_token(fullpath.release_value()).characters()); continue; } something_not_found = true; @@ -1075,12 +1075,12 @@ int Shell::builtin_kill(int argc, char const** argv) { // Simply translate the arguments and pass them to `kill' Vector<String> replaced_values; - auto kill_path = find_in_path("kill"sv); - if (kill_path.is_empty()) { + auto kill_path = Core::File::resolve_executable_from_environment("kill"sv); + if (!kill_path.has_value()) { warnln("kill: `kill' not found in PATH"); return 126; } - replaced_values.append(kill_path); + replaced_values.append(kill_path.release_value()); for (auto i = 1; i < argc; ++i) { if (auto job_id = resolve_job_spec({ argv[i], strlen(argv[1]) }); job_id.has_value()) { auto job = find_job(job_id.value()); |