1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +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:
Tim Schumacher 2022-08-20 18:31:03 +02:00 committed by Linus Groh
parent 39a3775f48
commit 5f99934dce
13 changed files with 74 additions and 95 deletions

View file

@ -179,12 +179,15 @@ int execve(char const* filename, char* const argv[], char* const envp[])
__RETURN_WITH_ERRNO(rc, rc, -1);
}
// https://linux.die.net/man/3/execvpe (GNU extension)
int execvpe(char const* filename, char* const argv[], char* const envp[])
{
if (strchr(filename, '/'))
return execve(filename, argv, envp);
ScopedValueRollback errno_rollback(errno);
// TODO: Make this use the PATH search implementation from Core::File.
String path = getenv("PATH");
if (path.is_empty())
path = DEFAULT_PATH;