CR-LF handling behavior of SED changed recently - this breaks a lot of MinGW cross build scripts
Brian Inglis
Brian.Inglis@SystematicSw.ab.ca
Wed Jun 7 19:26:00 GMT 2017
On 2017-06-07 11:23, Eric Blake wrote:
> On 06/07/2017 11:23 AM, Soegtrop, Michael wrote:
>> in the latest version of cygwin with sed-4.4-1.tar.bz2 the
>> behavior of sed regarding handling CR-LF sequences changed.
> And the change was documented (don't you read the release notes?)
> https://cygwin.com/ml/cygwin-announce/2017-02/msg00036.html
>> I would say that the documented behavior in both versions is that
>> they replace CR-LF with LF,
> No, the documented behavior is that CR-LF is converted to LF only
> for text-mounted files; but pipelines are default binary-mounted. If
> you want to strip CR from a pipeline, then make it explicit.
>> var=$( prog | sed .)
> Rewrite that to var=$( prog | tr -d '\r' | sed .)
For compatibility var=$( prog | sed -b -e 's/\r$//' ...)
>> Is this considered a bug in sed 4.4-1 or is the old behavior and
>> the -b option considered deprecated and it was just forgotten to
>> remove the documentation for the -b option?
> The -b option still works (forcing binary mode when you otherwise
> have a text mount); what changed was that the default behavior of
> pipelines is now binary instead of text, as binary is a better
> default mode for Linux compatibility.
Note that -b, --binary is not documented in any sed man page, only in
--help, and info pages (info -- sed -b), where it is explained as "This
option is available on every platform, but is only effective where the
operating system makes a distinction between text files and binary files".
On Cygwin that is now only files on text mounts; that also now applies
to many other Cygwin text utils: we have all had to make minor script
tweaks to deal with possible Windows text file input.
If you use sed -b -e 's/\r$//' where you currently use plain sed and
Windows text files may be input, it will work compatibly across platforms.
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
--
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
More information about the Cygwin
mailing list