delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/01/11/13:28:11

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
To: cygwin AT sourceware DOT cygnus DOT com
Subject: Re: Perl bug with DOS file line endings?
References: <BKEPJOHOPEADOFCGNACCOEANCMAA DOT ian AT underpressuredivers DOT com>
From: dkarr AT tcsi DOT com (David M. Karr)
Date: 11 Jan 2001 09:55:41 -0800
In-Reply-To: "Ian Puleston"'s message of "Wed, 10 Jan 2001 14:03:51 -0800"
Message-ID: <uysnmq2cte.fsf@tcsi.com>
Lines: 71
User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.6
MIME-Version: 1.0

>>>>> "Ian" == Ian Puleston <ian AT underpressuredivers DOT com> writes:
  Ian> Perl 5.6.1-1 seems to get confused as to whether its processing a DOS or
  Ian> Unix format file, depending on what shell it is run under. I'm using it in
  Ian> Windows 2000 to process a DOS format source file with line endings 0D0A
  Ian> (\r\n):

  Ian> When it is run directly from a DOS command prompt it works as expected and
  Ian> produces an output file with line endings 0D0A.

  Ian> When it is run from either bash or make initiated from a DOS command prompt,
  Ian> then it produces an output file with line endings 0D0D0A (\r\r\n). It seems
  Ian> that in this case it thinks that it is processing a Unix file, and has added
  Ian> a 0D to change from the Unix 0A line ending to the DOS 0D0A.

  Ian> I'm using CygWin make 3.79-3 and bash 2.04-5.

I'm having problems in this area also.  It seems like I get better
results if I set the input record separator ($/) to "\r\n", if the OS
is "cygwin" (the "$^O" variable).  However, it still doesn't seem to
fix everything.

I have the following little test case:

------------
#! /usr/local/bin/perl -w
if ($^O =~ /cygwin/)
{ $/ = "\r\n"; }

my $stuff = `echo abc`;
print ::stderr "stuff[" . $stuff . "]\n";
if ($stuff =~ /$\//)
{ print ::stderr "Found IRS in string.\n"; }

my $chompNum    = chomp $stuff;
print ::stderr "stuff[" . $stuff . "] chompNum[" . $chompNum . "]\n";
chop $stuff;
print ::stderr "stuff[" . $stuff . "]\n";
------------

On Solaris (with perl 5.005_03), I get the following (reasonable)
output:

--------------
stuff[abc
]
Found IRS in string.
stuff[abc] chompNum[1]
stuff[ab]
--------------

On NT/Cygwin, (with perl 5.6.1), I get the following (confusing)
output:

------------
stuff[abc
]
stuff[abc
] chompNum[0]
stuff[abc]
------------

When I send the output to a file and use "od -c" to view the output,
on NT, I see "\r \n" for each line ending.

This is probably another "binmode/textmode" issue, but I don't
understand it.

-- 
===================================================================
David M. Karr     ; w:(425)487-8312     ; TCSI & Best Consulting
dkarr AT tcsi DOT com    ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019