Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
sekiguchi-nagisa committed Apr 19, 2024
1 parent 8e617d9 commit d1b8a17
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/redir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,10 @@ static int doIOHere(const StringRef &value, int newFd, bool insertNewline) {

if (value.size() + (insertNewline ? 1 : 0) <= PIPE_BUF) {
int errnum = 0;
if (write(pipe[WRITE_PIPE], value.data(), sizeof(char) * value.size()) < 0) {
if (write(pipe[WRITE_PIPE], value.data(), value.size()) < 0 ||
write(pipe[WRITE_PIPE], "\n", insertNewline ? 1 : 0) < 0) {
errnum = errno;
}
if (insertNewline) { // for here str (insert newline)
if (errnum == 0 && write(pipe[WRITE_PIPE], "\n", 1) < 0) {
errnum = errno;
}
}
pipe.close();
return errnum;
} else {
Expand Down

0 comments on commit d1b8a17

Please sign in to comment.