Skip to content

Commit 1d0066a

Browse files
supercomputer7ADKaster
authored andcommitted
Userland/pls: Use Core::System::exec_command method to execute a command
1 parent 0d1af1a commit 1d0066a

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

Userland/Utilities/pls.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
4545
TRY(as_user.login());
4646

4747
TRY(Core::System::pledge("stdio rpath exec"));
48-
49-
Vector<StringView> exec_environment;
50-
for (size_t i = 0; environ[i]; ++i) {
51-
StringView env_view { environ[i], strlen(environ[i]) };
52-
auto maybe_needle = env_view.find('=');
53-
54-
if (!maybe_needle.has_value())
55-
continue;
56-
57-
// FIXME: Allow a custom selection of variables once ArgsParser supports options with optional parameters.
58-
if (!preserve_env && env_view.substring_view(0, maybe_needle.value()) != "TERM"sv)
59-
continue;
60-
61-
exec_environment.append(env_view);
62-
}
63-
64-
Vector<String> exec_arguments;
65-
exec_arguments.ensure_capacity(command.size());
66-
for (auto const& it : command)
67-
exec_arguments.append(it.to_string());
68-
69-
TRY(Core::System::exec(command.at(0), command, Core::System::SearchInPath::Yes, exec_environment));
48+
TRY(Core::System::exec_command(command, preserve_env));
7049
return 0;
7150
}

0 commit comments

Comments
 (0)