Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Tue, 22 Apr 2003 23:18:54 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: "Pierre A. Humblet" cc: cygwin AT cygwin DOT com Subject: Re: Erroneous line endings (cat,gawk,text mount) In-Reply-To: <20030423015254.GA38081907@hpn5170x> Message-ID: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 22 Apr 2003, Pierre A. Humblet wrote: > On Tue, Apr 22, 2003 at 07:54:17PM -0400, Igor Pechtchanski wrote: > > On Tue, 22 Apr 2003, Pierre A. Humblet wrote: > > > > > On Tue, Apr 22, 2003 at 10:54:41PM +0100, Peter S Tillier wrote: > > > > Replying to Igor Pechtchanski who wrote: > > > > > > > > > Also, "cat" will not translate line endings or anything at all -- > > > > > it's just a character-by-character copy of stdin to stdout. > > > > > > > > Fair enough (and what I expect it to be) thanks for the clarification. > > > > > > Igor, how do you explain the following behavior? > > > ~: od -c > > > abc > > > 0000000 a b c \n > > > 0000004 > > > ~: cat | od -c > > > abc > > > 0000000 a b c \r \n > > > 0000005 > > > This is with CYGWIN undefined and stty -igncr icrnl > > > I get the \r no matter what I try for CYGWIN and stty. > > > > > > Pierre > > > > Pierre, > > > > Simple - cat opens files (including stdin) in binary mode, and a Return on > > the console apparently sends a CRLF. Try, for example, "cat -s" -- it > > opens stdin in text mode, and you will not get a CR. I don't think there > > currently is an option that controls whether a console Return sends a CR. > > Intuitively, IMO, it should also be controlled by "binmode". I'm guessing > > it's just a matter of copying some code from pipe.cc to fhandler_console.cc > > Igor > > OK, but don't you expect "od" to also open files in binary mode? Not sure, have to look at the code. It's possible "cat" does some weird fcntl() magic that exposes a bug/feature. > And what do you make out of this? > ~: cat /dev/tty | od -c > abc > 0000000 a b c \n > 0000004 > > Pierre Ah, but won't this use a different fhandler altogether (fhandler_tty, not fhandler_console)? Although I *was* able to reproduce this in an xterm, which should have used fhandler_tty... Strange... Perhaps someone more knowledgeable in the innards of the tty/console code can chime in and explain things... Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! Knowledge is an unending adventure at the edge of uncertainty. -- Leto II -- 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/