On Mon, 14 Nov 2022 22:22:31 -0800, Ilya Zakharevich wrote:
grep with -a (or --text) option does not strip CR from line ends

That has been the case for over five years, as discussed about 2017-02, decided and announced in utilities releases that month (gawk, grep, sed) and earlier in bash IIRC, to avoid corrupting files and pipeliness by doing so, and for compatibility with other non-Windows systems; see discussions in threads:

        https://cygwin.com/legacy-ml/cygwin/2017-02/msg00152.html
        https://cygwin.com/legacy-ml/cygwin/2017-02/msg00188.html
        https://cygwin.com/legacy-ml/cygwin/2017-02/msg00189.html

This does not emit anything (contrary to the man page, which says:
      If grep decides the file is a text file, it strips the CR
      characters from the original file contents (to make regular
      expressions with ^ and $ work correctly).

That is under -U, --binary, where it also says:

"This option has no effect on platforms other than MS-DOS and MS-Windows."

Cygwin does not operate as DOS nor Windows, but does offer text mounts, which may still strip CRs from CR-LF EoL markers in *files*.

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

La perfection est atteinte                      Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter     not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer        but when there is no more to cut
                        -- Antoine de Saint-Exupéry

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to