mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
Userland/pls: Use Core::System::exec_command method to execute a command
This commit is contained in:
parent
0d1af1ad63
commit
1d0066a5cc
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(as_user.login());
|
||||||
|
|
||||||
TRY(Core::System::pledge("stdio rpath exec"));
|
TRY(Core::System::pledge("stdio rpath exec"));
|
||||||
|
TRY(Core::System::exec_command(command, preserve_env));
|
||||||
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));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue