public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Perl bug with DOS file line endings?
@ 2001-01-10 14:04 Ian Puleston
  2001-01-11  9:58 ` David M. Karr
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Puleston @ 2001-01-10 14:04 UTC (permalink / raw)
  To: cygwin

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

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

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

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



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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Perl bug with DOS file line endings?
  2001-01-10 14:04 Perl bug with DOS file line endings? Ian Puleston
@ 2001-01-11  9:58 ` David M. Karr
  0 siblings, 0 replies; 3+ messages in thread
From: David M. Karr @ 2001-01-11  9:58 UTC (permalink / raw)
  To: cygwin

>>>>> "Ian" == Ian Puleston <ian@underpressuredivers.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@tcsi.com    ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Perl bug with DOS file line endings?
       [not found] <BKEPJOHOPEADOFCGNACCOEDFCMAA.ipuleston@tutsys.com>
@ 2001-01-11 16:12 ` Ian Puleston
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Puleston @ 2001-01-11 16:12 UTC (permalink / raw)
  To: Cygwin

I've discovered that problem this doesn't happen if I specify the default
file format to be Unix when I install perl. However, specifying that on a
system that's using only DOS format files would seem somewhat
counter-intuitive?

I suspect that this is actually a bug and doing the above simply avoids it.

Ian

> I wrote:
>
> Perl 5.6.1-1 seems to get confused as to whether its processing a DOS or
> Unix format file, depending on what shell it is run under. I'm using it in
> Windows 2000 to process a DOS format source file with line endings 0D0A
> (\r\n):
>
> When it is run directly from a DOS command prompt it works as expected and
> produces an output file with line endings 0D0A.
>
> When it is run from either bash or make initiated from a DOS
> command prompt,
> then it produces an output file with line endings 0D0D0A
> (\r\r\n). It seems
> that in this case it thinks that it is processing a Unix file,
> and has added
> a 0D to change from the Unix 0A line ending to the DOS 0D0A.
>
> I'm using CygWin make 3.79-3 and bash 2.04-5.


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-01-11 16:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-01-10 14:04 Perl bug with DOS file line endings? Ian Puleston
2001-01-11  9:58 ` David M. Karr
     [not found] <BKEPJOHOPEADOFCGNACCOEDFCMAA.ipuleston@tutsys.com>
2001-01-11 16:12 ` Ian Puleston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).