This is the mail archive of the cygwin@sources.redhat.com 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]

Re: binmode in cygwin-1.1.4 (was: binmode in cygwin-1.1.3)


On Mon, Aug 07, 2000 at 02:27:07PM +0600, Igor Afanasyev wrote:
>>>In cygwin-1.1.3 when I extract files from a tar archive containing files
>>>with CRLF and redirect stdout to a file I get the file with CRCRLF.
>>>(tar -O -xf file.tar > qqq)
>>>
>>>To prevent this in cygwin-1.1.2 I set CYGWIN=binmode, but this doesn't work
>>>in cygwin-1.1.3.
>>>
>>>Can anyone please suggest what the problem is?
>
>CF> Sorry.  It looks like I screwed up the correspondence between "CYGWIN=binmode"
>CF> and stdin/stdout.
>
>CF> The only work-arounds that I can think of are:
>
>CF> 1) Fix tar so that -O sets stdout to O_BINARY (the correct fix).
>
>CF> 2) Do something like:
>
>CF>         sh -c "tar -O -xf file.tar > qqq"
>
>CF>    and make sure that qqq goes to a directory that is mounted with
>CF>    the -b option.
>
>Ugh, I'm mazed again.

>cygwin-1.1.4:
>
>1) Consider qqq goes to a directory that is mounted without the -b option (CYGWIN=binmode).
>
>If I issue
>
>sh.exe -c "tar -O -xf file.tar > qqq"
>
>qqq contains CRCRLF.
>
>If I issue
>
>cmd.exe /c "tar -O -xf file.tar > qqq"
>
>qqq contains CRLF.
>
>Why does output differ?

It has always differed, at least for a year or two.  binmode only
affects stdout when running from cmd.  You've obviously figured this out
from looking at the code.

Btw, its LF and CRLF.  Not CRLF and CRCRLF.

>2) Why hinfo::init_std_file_from_handle doesn't use __fmode anymore?

Because it is using the value set by CYGWIN=, like it always has.  I
made several changes in 1.1.3 to accomodate some new methods for dealing
with file open modes.  The change decoupled __fmode from CYGWIN=binmode.

>3) What is the precedence of CYGWIN=binmode, Program Options, mounting
>directories with the -b option, linking with binmode.o/textmode.o, explicit
>opening a file in binary/text mode? And how does it affect regular
>files and stdin/stdout?

Explicitly opening a file in binary/text mode takes precedence.

CYGWIN=binmode affects devices or pipes.  It also affects input/output
redirection from the command shell.

Otherwise, disk files are controlled by the mount table.

When you're using "sh", cygwin knows exactly what file has been opened
for stdout and the mount table controls that.  When you are using cmd,
cygwin has no idea what the output file is so CYGWIN=binmode controls
its behavior.

In 1.1.3 and 1.1.4 cygwin can also read from a table of filenames to
control how files are opened by default.  This requires making programmatic
changes, though.

Programs can also set the default input/output behavior by setting the __fmode
global.  This is how the binmode.o and textmode.o object files work.  Linking
your program with these files causes the default open behavior for files to
be either binmode or textmode.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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