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 Message-ID: <20020808144334.19031.qmail@web21002.mail.yahoo.com> Date: Thu, 8 Aug 2002 07:43:34 -0700 (PDT) From: Nicholas Wourms Subject: Re: Text commands behave differently under xterm... To: pat AT pat DOT net, cygwin AT cygwin DOT com In-Reply-To: <20020805163332.60947@pat.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hi Pat --- Pat wrote: > Hi, > > I've been tearing out my hair trying to figure out why text line > endings > are behaving differently under xterm and the plain NT shell.. > > First the obvious: > > echo | od -c > > shows that under an xterm I get \r\n, but under the regular NT > shell > I get simply \n. It's not even dependant on the terminal type... > It's > just magic. I guess I need a little clarification, but are you running these commands inside bash running inside cmd.exe or just plain cmd.exe? > So I tried to compensate by removing the extraneous CRs... but I > find > that a) sed starts inserting more returns and 2) tr breaks when > it's used > inside an eval. It's hard to come up with a test case because I > can't > construct the string in a guaranteed way... Here's a simple test > that requires > you put some NL term lines in a file for it: > > # File 'data' contains any NL terminated multiline data > # e.g. > # > # foo > # bar > # gee > # > # > # Now, why are these not the same? > # > cat file | sed '/foo/d' | tr -d \\015 | tr '\n' ';' | od -c > output=`cat file | sed '/foo/d' | tr -d \\015 | tr '\n' ';'` > echo $output | od -c > > > You'll see that the first line works as expected, removing the > CRs... but in > the second line they are back! It's as if using the evaluation > defeated the > tr somehow. > > Again - all of that only happens when I'm running an xterm... the > plain shell > works fine. > > I was so happy I was almost in tears to see the xterms working > under cygwin ;) > But now I'm really frustrated... Yes, I'm afraid cygwin does take a little getting used to, however it really works well once you get passed the quirks required to operate under Windows. For compatibility reasons, mixed-mode [text/binary] capabilities have been added to cygwin. I suspect, but am not positive, that you are probably experiencing the side effects of a text-mode mount. Would you mind posting the output of the mount command to the list? That would help in trying to figure out your problems. On my system, under X or under console bash, binmode produces the expected "\n" from your small testcase. That is my reasoning for my initial hypothesis. > Thanks, > Pat Niemeyer > Author of Learning Java, O'Reilly & Associates and the BeanShell As a side note, I just wanted to compliment you on doing such an outstanding job on Learning Java 1st Ed. I don't know about anyone else, but I look forward to picking up the brand new 2nd Ed soon. My O'reilly bookshelf wouldn't be complete without it ;-). Cheers, Nicholas __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/