mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Userland/pls: Use Core::System::exec_command method to execute a command
This commit is contained in:
parent
0d1af1ad63
commit
1d0066a5cc
Notes:
sideshowbarker
2024-07-17 04:45:34 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/1d0066a5cc Pull-request: https://github.com/SerenityOS/serenity/pull/15895 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/tslater2006
1 changed files with 1 additions and 22 deletions
|
@ -45,27 +45,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(as_user.login());
|
||||
|
||||
TRY(Core::System::pledge("stdio rpath exec"));
|
||||
|
||||
Vector<StringView> exec_environment;
|
||||
for (size_t i = 0; environ[i]; ++i) {
|
||||
StringView env_view { environ[i], strlen(environ[i]) };
|
||||
auto maybe_needle = env_view.find('=');
|
||||
|
||||
if (!maybe_needle.has_value())
|
||||
continue;
|
||||
|
||||
// FIXME: Allow a custom selection of variables once ArgsParser supports options with optional parameters.
|
||||
if (!preserve_env && env_view.substring_view(0, maybe_needle.value()) != "TERM"sv)
|
||||
continue;
|
||||
|
||||
exec_environment.append(env_view);
|
||||
}
|
||||
|
||||
Vector<String> exec_arguments;
|
||||
exec_arguments.ensure_capacity(command.size());
|
||||
for (auto const& it : command)
|
||||
exec_arguments.append(it.to_string());
|
||||
|
||||
TRY(Core::System::exec(command.at(0), command, Core::System::SearchInPath::Yes, exec_environment));
|
||||
TRY(Core::System::exec_command(command, preserve_env));
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue