Note the use of "rt" is non-standard, but we're restricting its use here to systems that define O_BINARY, which should invariably support "rt" mode.
* src/digest.c (): Where significant, explicitly use "rt" mode with --text, as MSYS2 defaults to binary mode for fopen'd files (though not for standard streams). * NEWS: Mention the bug fix. Fixes https://github.com/coreutils/coreutils/issues/123 --- NEWS | 6 ++++++ src/digest.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index e334a07fa..61d784252 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ GNU coreutils NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + md5sum --text correctly translates CRLF line endings with the MSYS2 runtime. + This also applies to the sha*sum and b2sum utilities. + [This bug was present in "the beginning".] + * Noteworthy changes in release 9.9 (2025-11-10) [stable] diff --git a/src/digest.c b/src/digest.c index 58b9c9ec1..f330bc1e9 100644 --- a/src/digest.c +++ b/src/digest.c @@ -1121,7 +1121,7 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result, } else { - fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r")); + fp = fopen (filename, O_BINARY ? (*binary ? "rb" : "rt") : "r"); if (fp == nullptr) { if (ignore_missing && errno == ENOENT) -- 2.51.1
