This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gawk Regression: CR characters are not stripped on Windows

On 2018-02-27 00:22, Orgad Shaneh wrote:
> Cross-posting per Eli Zaretskii's request.
> CR characters used to be automatically stripped on Windows (MSYS2 and
> Cygwin environments). This is broken in 4.2.0.

Cygwin binary mounts treat files as on Unix.

You missed all the discussions in early 2017 about gawk, grep, sed EOL handling:

following on from discussions about bash after ShellShock:

> Minimal example:
> echo -en "foo\r\n\r\nbar\r\n" > foo.txt
> awk '/^$/ { print "found" }' foo.txt # This worked with 4.1.4 and
> doesn't work with 4.2.0
> awk '/^\r$/ { print "found" }' foo.txt # This works with 4.2.0 and
> doesn't work with 4.1.4
>> Under MS-Windows, 'gawk' (and many other text programs) silently
>> translates end-of-line '\r\n' to '\n' on input and '\n' to '\r\n' on
>> output.

Cygwin does not try to be an MS Windows environment.
Cygwin tries its best to be a POSIX/Unix/Linux environment.

> and on Feb 8 the following section was added:
>> Recent versions of Cygwin open all files in binary mode.  This means
>> that you should use 'RS = "\r?\n"' in order to be able to handle
>> standard MS-Windows text files with carriage-return plus line-feed line
>> endings.

Use DOS files from a Cygwin text mount which does the conversion.

> This breaks compatibility between different gawk versions. What were
> the reasons for this change in cygwin, and why was it pushed upstream?

Compatibility with POSIX/Unix/Linux systems, except on a text mount, to allow
scripts which deal with binary data or embedded \r to work correctly, and
require scripts which work correctly, on Windows or Unix text as the application
provides, prefers, or ignores, and under Unix/Cygwin/Msys/Mingw.

Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]