Skip to content

Commit

Permalink
open pipe files in binary mode
Browse files Browse the repository at this point in the history
This avoids double \r when copying the file that already has \r\n.
  • Loading branch information
stsp committed Apr 23, 2024
1 parent 2147a36 commit b85da89
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -4237,9 +4237,9 @@ static void exec_cmd(int call)
pipe_fno[STDIN_INDEX] = open(pipe_file[STDIN_INDEX], O_TEXT|O_RDONLY, S_IRUSR);

if (pipe_file_redir_count[STDOUT_INDEX] > 1)
pipe_fno[STDOUT_INDEX] = open(pipe_file[STDOUT_INDEX], O_TEXT|O_WRONLY|O_APPEND|O_CREAT, S_IWUSR); // open for append
pipe_fno[STDOUT_INDEX] = open(pipe_file[STDOUT_INDEX], O_BINARY|O_WRONLY|O_APPEND|O_CREAT, S_IWUSR); // open for append
else if (pipe_file_redir_count[STDOUT_INDEX] == 1)
pipe_fno[STDOUT_INDEX] = open(pipe_file[STDOUT_INDEX], O_TEXT|O_WRONLY|O_TRUNC|O_CREAT, S_IWUSR); // open as new file
pipe_fno[STDOUT_INDEX] = open(pipe_file[STDOUT_INDEX], O_BINARY|O_WRONLY|O_TRUNC|O_CREAT, S_IWUSR); // open as new file

/* check for error
if (pipe_fno[pipe_index] < 0 ||
Expand Down

0 comments on commit b85da89

Please sign in to comment.