Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > gnu.utils.bug > #2217
| From | Eli Zaretskii <eliz@gnu.org> |
|---|---|
| Newsgroups | gnu.utils.bug |
| Subject | Re: Bug in grep.exe |
| Date | 2017-08-26 14:04 +0300 |
| Message-ID | <mailman.13836.1503745514.21957.bug-gnu-utils@gnu.org> (permalink) |
| References | <CAGegeDjXFwae04ckWBz1m2x_HP=zq1gH8-8Xsyk05+UPXk21Aw@mail.gmail.com> |
> 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
Re: Bug in grep.exe Eli Zaretskii <eliz@gnu.org> - 2017-08-26 14:04 +0300
csiph-web