Skip to content

Commit 03efcb5

Browse files
committed
erts: Only translate \r\n on character devices in fd ports
If the input handle is a pipe or something different we don't want to do any translation at all, but if it is a character device we translate \r\n to \n so that it mimics how terminals on Linux works a little bit better. As open_port fd is not used anymore for the normal erlang terminal this change only effects thirdparty usage which usually is from pipes that do not want any translation to happen. Closes #10258
1 parent c388a2d commit 03efcb5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • erts/emulator/sys/win32

erts/emulator/sys/win32/sys.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,11 @@ fd_start(ErlDrvPort port_num, char* name, SysDriverOpts* opts)
21792179
return ERL_DRV_ERROR_GENERAL;
21802180
}
21812181

2182-
dp->in.flags = DF_XLAT_CR;
2182+
/* If input is a terminal, we translate \r\n to \n */
2183+
if (GetFileType(opts->ifd) == FILE_TYPE_CHAR) {
2184+
dp->in.flags = DF_XLAT_CR;
2185+
}
2186+
21832187
if (is_std_error) {
21842188
dp->out.flags |= DF_DROP_IF_INVH; /* Just drop messages if stderror
21852189
is an invalid handle */

0 commit comments

Comments
 (0)