delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/04/14:04:28

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 4 Nov 2004 14:04:33 -0500
From: Christopher Faylor <cgf-no-personal-reply-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Perl binmode problem on text mount
Message-ID: <20041104190433.GJ11533@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <418A779A DOT 6080808 AT agilent DOT com> <NUTMEGmZ5fgSdmlm1DT000004d6 AT NUTMEG DOT CAM DOT ARTIMI DOT COM>
Mime-Version: 1.0
In-Reply-To: <NUTMEGmZ5fgSdmlm1DT000004d6@NUTMEG.CAM.ARTIMI.COM>
User-Agent: Mutt/1.4.1i

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 AT mace /win/textmode/c> od -c foo.txt
>0000000   H   e   l   l   o  \n
>0000006
>dk AT mace /win/textmode/c> od -c < foo.txt
>0000000   H   e   l   l   o  \r  \n
>0000007
>dk AT 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/

- Raw text -


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