mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
UE: Don't look up binaries in PATH when the user specified a full path
When the user specifies a path such as ./test we'd incorrectly look for the binary in the PATH environment variable and end up executing an incorrect binary (e.g. /bin/test). We should only look up binaries in PATH if the user-specified path does not contain a slash.
This commit is contained in:
parent
26e711f953
commit
ee6600ea24
1 changed files with 7 additions and 6 deletions
|
@ -26,13 +26,14 @@ int main(int argc, char** argv, char** env)
|
||||||
parser.add_positional_argument(arguments, "Command to emulate", "command");
|
parser.add_positional_argument(arguments, "Command to emulate", "command");
|
||||||
parser.parse(argc, argv);
|
parser.parse(argc, argv);
|
||||||
|
|
||||||
auto executable_path = Core::find_executable_in_path(arguments[0]);
|
String executable_path;
|
||||||
if (executable_path.is_empty()) {
|
if (arguments[0].contains("/"sv))
|
||||||
executable_path = Core::File::real_path_for(arguments[0]);
|
executable_path = Core::File::real_path_for(arguments[0]);
|
||||||
if (executable_path.is_empty()) {
|
else
|
||||||
reportln("Cannot find executable for '{}'.", executable_path);
|
executable_path = Core::find_executable_in_path(arguments[0]);
|
||||||
return 1;
|
if (executable_path.is_empty()) {
|
||||||
}
|
reportln("Cannot find executable for '{}'.", arguments[0]);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<String> environment;
|
Vector<String> environment;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue