Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > gnu.utils.bug > #2217

Re: Bug in grep.exe

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Eli Zaretskii <eliz@gnu.org>
Newsgroups gnu.utils.bug
Subject Re: Bug in grep.exe
Date Sat, 26 Aug 2017 14:04:58 +0300
Lines 34
Approved bug-gnu-utils@gnu.org
Message-ID <mailman.13836.1503745514.21957.bug-gnu-utils@gnu.org> (permalink)
References <CAGegeDjXFwae04ckWBz1m2x_HP=zq1gH8-8Xsyk05+UPXk21Aw@mail.gmail.com>
Reply-To Eli Zaretskii <eliz@gnu.org>
NNTP-Posting-Host lists.gnu.org
X-Trace usenet.stanford.edu 1503745515 14893 208.118.235.17 (26 Aug 2017 11:05:15 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-gnu-utils@gnu.org
To Nicholas Hawthorn <nickhawthorn2@gmail.com>
Envelope-to bug-gnu-utils@gnu.org
In-reply-to <CAGegeDjXFwae04ckWBz1m2x_HP=zq1gH8-8Xsyk05+UPXk21Aw@mail.gmail.com> (message from Nicholas Hawthorn on Sat, 26 Aug 2017 12:03:58 +1200)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 2001:4830:134:3::e
X-BeenThere bug-gnu-utils@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU utilities <bug-gnu-utils.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-gnu-utils>, <mailto:bug-gnu-utils-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-gnu-utils/>
List-Post <mailto:bug-gnu-utils@gnu.org>
List-Help <mailto:bug-gnu-utils-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-gnu-utils>, <mailto:bug-gnu-utils-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.utils.bug:2217

Show key headers only | View raw


> From: Nicholas Hawthorn <nickhawthorn2@gmail.com>
> Date: Sat, 26 Aug 2017 12:03:58 +1200
> 
> Say we make a one line text file called "a" that contains
>     w  CR  LF
> 
> and then give the command:
>     grep -v "<" < a > b
> 
> File "b" will consist of:
>     w  LF
> 
> In effect, grep has removed the CR.

Yes, and this is a feature.  The exact command-line arguments are
unimportant: Grep on Windows _always_ strips CR characters from
Windows-style CRLF EOLs, and never adds them back when writing output
to files or pipes.  This is because the alternative, of always adding
CR to LF-only Unix-style EOLs, which is what Windows text-mode output
would do, is much worse and will break many scripts and test suites.
It would also make it impossible to output anything past the first ^Z
byte, which serves as a "software EOF" indicator.

> The bug was first found in a 66 line .bat file where it was a bit of
> a nuisance.

Why is that a problem in a batch file?  AFAIK, the stock Windows shell
in modern versions of MS-Windows has no problems running batch files
with Unix-style LF-only EOLs, unlike on old versions of the OS.

P.S. I think (but I'm not sure) latest versions of Grep removed this
feature, so perhaps you will be better off if you upgrade your Grep
installation.

Back to gnu.utils.bug | Previous | Next | Find similar


Thread

Re: Bug in grep.exe Eli Zaretskii <eliz@gnu.org> - 2017-08-26 14:04 +0300

csiph-web