From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77295 invoked by alias); 5 Mar 2018 13:36:12 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 76612 invoked by uid 89); 5 Mar 2018 13:36:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Minimal, arnold, 4.2.0, states X-HELO: freefriends.org Received: from freefriends.org (HELO freefriends.org) (96.88.95.60) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Mar 2018 13:36:08 +0000 X-Envelope-From: arnold@skeeve.com Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.9/8.14.9) with ESMTP id w25Da6LN018345; Mon, 5 Mar 2018 06:36:06 -0700 Received: (from arnold@localhost) by freefriends.org (8.14.9/8.14.9/submit) id w25Da6xe018344; Mon, 5 Mar 2018 13:36:06 GMT From: arnold@skeeve.com Message-Id: <201803051336.w25Da6xe018344@freefriends.org> Date: Mon, 05 Mar 2018 13:36:00 -0000 To: orgads@gmail.com, eliz@gnu.org, cygwin@cygwin.com, bug-gawk@gnu.org Subject: Re: [bug-gawk] gawk Regression: CR characters are not stripped on Windows References: In-Reply-To: User-Agent: Heirloom mailx 12.4 7/29/08 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2018-03/txt/msg00057.txt.bz2 Is there a way to distinguish cygwin from msys at compile time? I would not object to restoring the behavior for msys only. Thanks, Arnold Orgad Shaneh wrote: > Hi, > > 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. > > 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 > > Bisected to commit 5db38f775d9ba239e125d81dff2010a2ddacb48e: > (* gawkmisc.c (cygwin_premain0, cygwin_premain2): Remove. > No longer needed). > > Apparently it's still needed... > > This issue was reported in https://github.com/git-for-windows/git/issues/1524 > > Proposed patch is attached. > > As Eli said, this change was deliberate. But this has several drawbacks. > > 1. The gawk info page states that: > > > 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. > > 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. > > This breaks compatibility between different gawk versions. What were > the reasons for this change in cygwin, and why was it pushed upstream? > > 2. Git and other tools automatically convert text files to CRLF on > Windows. This means that any awk script that runs on both platforms > must use RS = "\r?\n". One example that was broken by this behavior > change is gerrit's commit-msg hook[1], which scans for empty lines by > /^$/ regexp. > > Please consider reverting this change. Patch attached. > > [1] https://gerrit.googlesource.com/gerrit/+/376a7bbb64f1b3f13c261f4efa0af0e8538cfe9b/resources/com/google/gerrit/server/tools/root/hooks/commit-msg#101 > > - Orgad -- 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