diff --git a/Userland/Utilities/pls.cpp b/Userland/Utilities/pls.cpp index 7ada606c75..356eff18ff 100644 --- a/Userland/Utilities/pls.cpp +++ b/Userland/Utilities/pls.cpp @@ -45,11 +45,18 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath exec")); - Vector exec_environment_strings; Vector exec_environment; - if (auto* term = getenv("TERM")) { - exec_environment_strings.append(String::formatted("TERM={}", term)); - exec_environment.append(exec_environment_strings.last()); + for (size_t i = 0; environ[i]; ++i) { + StringView env_view { environ[i] }; + auto maybe_needle = env_view.find('='); + + if (!maybe_needle.has_value()) + continue; + + if (env_view.substring_view(0, maybe_needle.value()) != "TERM"sv) + continue; + + exec_environment.append(env_view); } Vector exec_arguments;