From 1d0066a5ccba8597c87bd5b9424388ca53a605c4 Mon Sep 17 00:00:00 2001 From: Liav A Date: Fri, 4 Nov 2022 11:54:29 +0200 Subject: [PATCH] Userland/pls: Use Core::System::exec_command method to execute a command --- Userland/Utilities/pls.cpp | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/Userland/Utilities/pls.cpp b/Userland/Utilities/pls.cpp index 13c4f03d86..29e0f251b5 100644 --- a/Userland/Utilities/pls.cpp +++ b/Userland/Utilities/pls.cpp @@ -45,27 +45,6 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(as_user.login()); TRY(Core::System::pledge("stdio rpath exec")); - - Vector 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 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; }