mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
paste: Use Core::System::{exec,setenv}
This commit is contained in:
parent
32ab09a930
commit
5a47b74227
1 changed files with 4 additions and 5 deletions
|
@ -16,9 +16,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static void spawn_command(Vector<char const*> const& command, ByteBuffer const& data, char const* state)
|
static void spawn_command(Span<StringView> command, ByteBuffer const& data, char const* state)
|
||||||
{
|
{
|
||||||
auto pipefd = MUST(Core::System::pipe2(0));
|
auto pipefd = MUST(Core::System::pipe2(0));
|
||||||
pid_t pid = MUST(Core::System::fork());
|
pid_t pid = MUST(Core::System::fork());
|
||||||
|
@ -28,8 +27,8 @@ static void spawn_command(Vector<char const*> const& command, ByteBuffer const&
|
||||||
MUST(Core::System::dup2(pipefd[0], 0));
|
MUST(Core::System::dup2(pipefd[0], 0));
|
||||||
MUST(Core::System::close(pipefd[0]));
|
MUST(Core::System::close(pipefd[0]));
|
||||||
MUST(Core::System::close(pipefd[1]));
|
MUST(Core::System::close(pipefd[1]));
|
||||||
setenv("CLIPBOARD_STATE", state, true);
|
MUST(Core::System::setenv("CLIPBOARD_STATE", state, true));
|
||||||
execvp(command[0], const_cast<char**>(command.data()));
|
MUST(Core::System::exec(command[0], command, Core::System::SearchInPath::Yes));
|
||||||
perror("exec");
|
perror("exec");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
bool print_type = false;
|
bool print_type = false;
|
||||||
bool no_newline = false;
|
bool no_newline = false;
|
||||||
bool watch = false;
|
bool watch = false;
|
||||||
Vector<char const*> watch_command;
|
Vector<StringView> watch_command;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("Paste from the clipboard to stdout.");
|
args_parser.set_general_help("Paste from the clipboard to stdout.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue