delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/04/12:40:15

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 12:40:18 -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: <20041104174018.GD11533@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <41897FF4 DOT 1080501 AT agilent DOT com> <Pine DOT GSO DOT 4 DOT 61 DOT 0411032211380 DOT 687 AT slinky DOT cs DOT nyu DOT edu> <4189BC6E DOT 8060009 AT agilent DOT com> <20041104163029 DOT GC11533 AT trixie DOT casa DOT cgf DOT cx> <Pine DOT GSO DOT 4 DOT 61 DOT 0411041217450 DOT 25828 AT slinky DOT cs DOT nyu DOT edu>
Mime-Version: 1.0
In-Reply-To: <Pine.GSO.4.61.0411041217450.25828@slinky.cs.nyu.edu>
User-Agent: Mutt/1.4.1i

On Thu, Nov 04, 2004 at 12:28:33PM -0500, Igor Pechtchanski wrote:
>On Thu, 4 Nov 2004, Christopher Faylor wrote:
>
>> On Wed, Nov 03, 2004 at 09:21:50PM -0800, Earl Chew wrote:
>> >Igor Pechtchanski wrote:
>> >>On Wed, 3 Nov 2004, Earl Chew wrote:
>> >>
>> >>>This code used to work on Perl 5.6.1-2 on Cygwin 1.3.10.
>> >>>
>> >>>I've now moved to Perl 5.8.5-3 on Cygwin 1.5.11.
>> >>>
>> >>>Here is the Perl program:
>> >>>
>> >>>	binmode STDOUT;
>> >>>	print "Hello\n";
>> >>>
>> >>>1. Output to file on text mount
>> >>>
>> >>>	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
>> >[ .. snip .. ]
>> >>This is expected behavior.  Unless you use raw writes (as "cat" does), the
>> >>mode of the file (text or binary) is determined *by the program that opens
>> >>the file*.  In the above case, the program is not perl, it's your shell.
>> >
>> >I think you're telling me that "binmode STDOUT" has no effect. I find
>> >this counterintuitive.
>> >
>> >Without "binmode STDOUT", I can see how your explanation would work.
>>
>> AFAIK, binmode STDOUT should work fine.  It should eventually translate
>> to the setmode call.
>
>Do you mean the "set_flags" call?

No.

>> Since setmode takes an fd argument it obviously should affect the mode
>> of the file being read or written regardless of how it was originally
>> opened.
>
>I used the command-line version of the above script:
>
>strace -o bmode.strace perl -e 'binmode STDOUT;print "Hello\n"' > foo.txt
>
>bmode.strace was only ~350 lines, and it seems to show that the mode of fd
>1 is set to text based on the mount info, and never reset to binary
>afterwards.  fhandler_base::write reports a text write.  So it does look
>like "binmode STDOUT" doesn't work...  What am I missing?

You are missing the fact that the OP was reporting a real bug, apparently.

cgf

--
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