This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Perl binmode problem on text mount


On Thu, Nov 04, 2004 at 06:52:03PM -0000, Dave Korn wrote:
>> -----Original Message-----
>> From: cygwin-owner On Behalf Of Earl Chew
>> Sent: 04 November 2004 18:40
>
>> Christopher Faylor wrote:
>> > You are missing the fact that the OP was reporting a real 
>> bug, apparently.
>> 
>> To confirm, I ran the program:
>> 
>> 	binmode STDOUT;
>> 	print "Hello\n";
>> 
>> using Perl 5.6.1-2 on Cygwin 1.5.11:
>> 
>> 	perl foo.pl > foo.txt ; od -c foo.txt
>> 
>> 	0000000  H e l l o \r \n	# Perl 5.8.5-3 Cygwin 1.5.11
>> 	0000000  H e l l o \n		# Perl 5.6.1-2 Cygwin 1.3.10
>> 	0000000  H e l l o \n		# Perl 5.6.1-2 Cygwin 1.5.11
>> 
>> The problem appears to be related to a change in Perl, rather
>> than Cygwin.
>
>  ....or maybe a change in 'od' ?

Hard to see how "od" would take previous versions of perl into account.

>Trying to understand problems like this mangles my brain.  Ok, there's
>perl's file descriptor, that's in binmode.  But then it's being
>redirected to a file.  By a shell.  What mode do shell redirections
>happen in?  And then the file in question is getting written to a
>textmode mount.  Which we'd expect to be changing it.  And then it gets
>read back by 'od'.  From a text mount.  Via a file open, rather than a
>redirection.  There's just waaaay too many potential changes of mode to
>keep track of!

setmode() should trump everything.  If a program calls setmode() on an
open file descriptor, future operations on that file should honor what
setmode() says.

binmode in perl always used to call setmode (back in the dim past when I
was maintaining perl for cygwin).  It just sounds like this is a bug.

>  If you doubt that it's as complicated as I make out, check this example:
>
>dk@mace /win/textmode/c> od -c foo.txt
>0000000   H   e   l   l   o  \n
>0000006
>dk@mace /win/textmode/c> od -c < foo.txt
>0000000   H   e   l   l   o  \r  \n
>0000007
>dk@mace /win/textmode/c>
>
>  I wouldn't like to jump to *any* hasty conclusions about whether or not I
>know what the _actual_ contents of this file are just by looking at it with
>od........

The OP showed consistent behavior using od and different versions of perl.
There is no reason to speculate about od problems in this scenario.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]