This is the mail archive of the
cygwin
mailing list for the Cygwin project.
AW: gawk 4.1.4: CR separate char for CRLF files
- From: Roger Krebs <Roger dot Krebs at stage-entertainment dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Wed, 9 Aug 2017 07:03:24 +0000
- Subject: AW: gawk 4.1.4: CR separate char for CRLF files
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Roger dot Krebs at stage-entertainment dot com;
- References: <004401d3109c$2dcb09e0$89611da0$@gmx.net> <598a47fc.5501ca0a.5476f.0305@mx.google.com> <004701d310a9$372363e0$a56a2ba0$@gmx.net>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Hi,
I've added a BEGIN section at the beginning awk sript file setting the record separator explicitly for the input file (RS) as well as for the output file (ORS):
BEGIN {
RS="\r\n"
ORS="\r\n"
}
{
... your script
}
Especially the RS parameter wasn't necessary in the past but now it is.
It works in all my cases. The only disadvantage: you have to know what kind of files you want to handle in the awk script. The same awk script will not work for DOS files as well as for linux files.
Best
Roger
-----Ursprüngliche Nachricht-----
Von: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com] Im Auftrag von Jannick
Gesendet: Mittwoch, 9. August 2017 02:48
An: cygwin@cygwin.com
Betreff: RE: gawk 4.1.4: CR separate char for CRLF files
On Tue, 08 Aug 2017 16:23:40 -0700 (PDT), Steven Penny wrote:
> On Wed, 9 Aug 2017 01:15:08, "Jannick" wrote:
> > the current version 4.1.4 of gawk appears to unpleasantly treat CR for
> > CRLF files, i.e. CR is not gracefully swallowed, but is a separate
character.
> >
> > This makes some, if not all, of the scripts we are working with here
> > useless, unless the input files are converted to LF which certainly is
> > not feasible. IIRC the issue did not show up some versions back.
> >
> > Is this a bug - or am I missing something here?
>
> Learn to read:
>
> http://cygwin.com/ml/cygwin/2017-08/msg00033.html
Thanks - quickly done.
The link reveals that CRLF/LF conversion is now mandatory to work with
cygwin's gawk on DOS machines. As far as I can see there is no legacy
solution like for, e.g., sed (-b switch) to have an easy solution for the
issue, especially when invoking gawk from makefiles (piping).
I consider this bad news while admittedly not fully understanding the whole
background of the move which is not necessary for now.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple