From: jyh AT cs DOT cornell DOT edu (Jason Hickey) Subject: Re: Problem with stdout BINARY 12 Jun 1997 23:54:48 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199706121504.LAA21586.cygnus.gnu-win32@cloyd.cs.cornell.edu> References: <199706112129 DOT QAA07866 AT edge DOT edge DOT net> Original-To: gnu-win32 AT cygnus DOT com (Cygnus gnuwin32) In-Reply-To: <199706112129.QAA07866@edge.edge.net> X-Face: $tsnqT``tn7U3/uW*Z+d=O5bh1'T^86$3I(2EL0^#]WvS6~GV41O5CQlf2}8#N,m>DFK}Ya` Wux,YSwY~w|CyQF?y1xruG]qR%BxY=Wcs)?|/ Original-Sender: owner-gnu-win32 AT cygnus DOT com Blake McBride writes: > At 11:29 AM 6/11/97 +0100, you wrote: > >Hi everybody, > > > >Trying to write gif file in stdout with 'putchar'. b18 seems to add a CRNL > >every CR he > >founds in the file. > > You know it's one of life's great mysteries. stdxxx used to be opened in > binary mode and then someone changed it. It seems to me that it's got > to be trivial to switch it back. The reason for changing it is unknown > to me. Since they've changed it to TEXT mode you can't even execute: > > gzip -dc abc.tar.gz |tar xvf - > > anymore. I don't have time to find and fix the problem for my own use > and this is the only reason I don't use gnu-win32. > > --blake I've run into the same problem--for instance, if "x" is a binary file, the commands "dd if=x of=y" and "dd if=x > y" produce different results ("cat x > y" doesn't work because cat opens its input in TEXT mode). This is an incredible headache, but the fix is pretty easy. You need to recompile bash, which always opens redirects in TEXT mode. You can download my patched copy of bash at http://www.cs.cornell.edu/home/jyh/cygwin32/ or you can just patch the file "make_cmd.c" with the following patch: *** make_cmd.c Thu Jun 12 10:22:38 1997 --- x Thu Jun 12 11:02:02 1997 *************** *** 467,494 **** case r_output_direction: /* >foo */ case r_output_force: /* >| foo */ - #ifndef TEXT_MODE - temp->flags = O_TRUNC | O_WRONLY | O_CREAT | O_BINARY; - #else temp->flags = O_TRUNC | O_WRONLY | O_CREAT; - #endif break; case r_input_direction: /* flags = O_RDONLY | O_BINARY; - #else temp->flags = O_RDONLY; - #endif break; case r_appending_to: /* >>foo */ - #ifndef TEXT_MODE - temp->flags = O_APPEND | O_WRONLY | O_CREAT | O_BINARY; - #else temp->flags = O_APPEND | O_WRONLY | O_CREAT; - #endif break; case r_deblank_reading_until: /* <<-foo */ --- 467,482 ---- *************** *** 503,521 **** break; case r_err_and_out: /* command &>filename */ - #ifndef TEXT_MODE - temp->flags = O_TRUNC | O_WRONLY | O_CREAT | O_BINARY; - #else temp->flags = O_TRUNC | O_WRONLY | O_CREAT; - #endif break; case r_input_output: - #ifndef TEXT_MODE - temp->flags = O_RDWR | O_CREAT | O_BINARY; - #else temp->flags = O_RDWR | O_CREAT; - #endif break; default: --- 491,501 ---- -- Jason Hickey Email: jyh AT cs DOT cornell DOT edu Department of Computer Science Tel: (607) 255-1372 Cornell University - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".