From 5a47b74227d41bdf8af1f2da7e232002f6ad06a2 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 12 Mar 2022 20:24:56 +0000 Subject: [PATCH] paste: Use Core::System::{exec,setenv} --- Userland/Utilities/paste.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Userland/Utilities/paste.cpp b/Userland/Utilities/paste.cpp index 910dc34a52..4083ef0207 100644 --- a/Userland/Utilities/paste.cpp +++ b/Userland/Utilities/paste.cpp @@ -16,9 +16,8 @@ #include #include #include -#include -static void spawn_command(Vector const& command, ByteBuffer const& data, char const* state) +static void spawn_command(Span command, ByteBuffer const& data, char const* state) { auto pipefd = MUST(Core::System::pipe2(0)); pid_t pid = MUST(Core::System::fork()); @@ -28,8 +27,8 @@ static void spawn_command(Vector const& command, ByteBuffer const& MUST(Core::System::dup2(pipefd[0], 0)); MUST(Core::System::close(pipefd[0])); MUST(Core::System::close(pipefd[1])); - setenv("CLIPBOARD_STATE", state, true); - execvp(command[0], const_cast(command.data())); + MUST(Core::System::setenv("CLIPBOARD_STATE", state, true)); + MUST(Core::System::exec(command[0], command, Core::System::SearchInPath::Yes)); perror("exec"); exit(1); } @@ -53,7 +52,7 @@ ErrorOr serenity_main(Main::Arguments arguments) bool print_type = false; bool no_newline = false; bool watch = false; - Vector watch_command; + Vector watch_command; Core::ArgsParser args_parser; args_parser.set_general_help("Paste from the clipboard to stdout.");