Honor --ors crlf for CSV output (#1810) (#2150)

* Honor --ors CRLF for CSV output (#1810)

The full-CSV record writer validated ORS as newline or
carriage-return/newline, but never propagated the choice to the forked
Go CSV writer's UseCRLF field, so `--ors '\r\n'` (or `--ors crlf`)
silently produced LF line endings. Set UseCRLF from the writer options
so CRLF output is honored. Default behavior (LF) is unchanged, and
other ORS values are still rejected. The CSV-lite and TSV writers
already honored CRLF ORS.

Also: fix a copy-paste "for CSV" in the TSV writer's ORS-validation
message, add unit tests asserting byte-exact line endings (the regtest
harness normalizes CR/LF, so this can't be asserted in test/cases), add
CLI-level regression cases, and update the separators documentation.

This substantially addresses #1722 as well: RFC-4180-style CRLF output
can now be requested on any platform.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Fix errcheck lint: check Flush() error in CSV writer test

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
John Kerl 2026-07-05 20:35:32 -04:00 committed by GitHub
parent c6986f90e9
commit ac08b072dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 185 additions and 15 deletions

View file

@ -840,6 +840,9 @@ This is simply a copy of what you should see on running `man mlr` at a command p
* Default line endings (`--irs` and `--ors`) are newline
which is interpreted to accept carriage-return/newline files (e.g. on Windows)
for input, and to produce platform-appropriate line endings on output.
* For CSV, CSV-lite, TSV, and TSV-lite output, ORS may be either newline (the
default) or carriage-return/newline: e.g. `--ors crlf` or `--ors '\r\n'`
for RFC-4180-style line endings on any platform.
Notes about all other separators:
@ -4045,5 +4048,5 @@ This is simply a copy of what you should see on running `man mlr` at a command p
MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite
https://miller.readthedocs.io
2026-07-05 4mMILLER24m(1)
2026-07-06 4mMILLER24m(1)
</pre>