From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17557 invoked from network); 2 Apr 2004 17:02:09 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 2 Apr 2004 17:02:09 -0000 Received: (qmail 2629 invoked by alias); 2 Apr 2004 17:01:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19723 Received: (qmail 2617 invoked from network); 2 Apr 2004 17:01:57 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 2 Apr 2004 17:01:57 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [130.225.247.86] by sunsite.dk (MessageWall 1.0.8) with SMTP; 2 Apr 2004 17:1:57 -0000 Received: (qmail 32515 invoked from network); 2 Apr 2004 17:01:56 -0000 Received: from ip-66-80-62-153.dsl.sca.megapath.net (HELO ripple.fruitbat.org) (66.80.62.153) by a.mx.sunsite.dk with SMTP; 2 Apr 2004 17:01:55 -0000 Received: (from daemon@localhost) by ripple.fruitbat.org (8.10.2/8.8.8/PAC-1.3) id i32H0gq06250; Fri, 2 Apr 2004 09:00:42 -0800 Received: from ming.fruitbat.org(192.168.1.2) by ripple.fruitbat.org via smap (V2.1/2.1+anti-relay+anti-spam) id xma006247; Fri, 2 Apr 04 08:59:49 -0800 Received: from gremlin.fruitbat.org (IDENT:202@gremlin.fruitbat.org [192.168.1.4]) by ming.fruitbat.org (8.10.2/8.10.2/PAC-1.6) with ESMTP id i32Hxni28707; Fri, 2 Apr 2004 09:59:49 -0800 Date: Fri, 2 Apr 2004 08:59:54 -0800 (PST) From: "Peter A. Castro" To: Dave Korn cc: zsh-workers@sunsite.dk, cygwin@cygwin.com Subject: RE: zsh and line breaks In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 On Fri, 2 Apr 2004, Dave Korn wrote: Hi Dave, > > -----Original Message----- > > From: cygwin-owner On Behalf Of Peter A. Castro > > Sent: 01 April 2004 22:21 > > > In system.h I've added a #define in the #ifdef > > __CYGWIN__ section of: > > #define ORO_TEXT | O_TEXT > > And for the #else case: > > #define ORO_TEXT > > > > Then in code which needs it I have modified it to look like this: > > > > if ((fd = open(name, O_RDONLY ORO_TEXT)) < 0) { > > > > It's really just utilizing the macro ability of the compiler, > > and it's a > > style judgement call. I don't have a problem with it, obviously, but > > others might look at it and wonder how it could possible > > compile if they > > didn't look in system.h first. If you think that might present > > confusion, then I'll change it to be explicitly "| OR_TEXT" and have > > #define O_TEXT to be 0 if not defined at all. > > > > Any thoughts on this? > > It's pretty reasonable but as you say could be confusing. Here's another > approach that might seem nicer because it's kind of function-like: > > #ifdef __CYGWIN__ > #define MAYBE_ADD_O_TEXT_FLAG(x) (O_TEXT | (x)) > #else > #define MAYBE_ADD_O_TEXT_FLAG(x) (x) > #endif > > Then say > > if ((fd = open(name, MAYBE_ADD_O_TEXT_FLAG(O_RDONLY))) < 0) { > > You might well want to choose a better name for the function-like macro than > that, but I think the pattern is slightly clearer. It's always interesting to see how people solve the same problem using a different style. Yes, I'd though of using a wrapper macro, but decided I didn't want to change mainline code that much. I'm really looking for something that's pretty non-intrusive. Corinna just emailed a possible solution, which may be the best yet because it works at a lower level and wouldn't require all of those 43 open calls to be changed! > > The primary problem is with running scripts with CR/LFs. > > That gets fixed > > with adding O_TEXT everywhere. A secondary problem is with redirected > > input and/or output which is processed by the shell. > > > > I've been reviewing this problem and I think maybe I've been > > attacking it > > incorrectly. I had though that adding O_TEXT everywhere > > would solve this > > problem. However, the environment is complicating things :) > > > > Here's the deal: > > > So where the file located in the filesystem > > determines > > the default handling of translation when opened as a text file. > > This is for normal unix style coding of opens without any O_TEXT or > > O_BINARY cruft. > > > > Now, adding an explicit O_TEXT or O_BINARY forces one mode or > > the other, > > ignoring the filesystem mount attributes. The problem is, I > > don't want > > to force the mode, > > > > Thanks for listening. Any suggestions are welcome. > > Doesn't the POSIX standard specify something about shells should open > stdin, stdout and stderr in textmode? IOW, aren't you obliged to force the > mode? The posix standard specifies a textmode should be used, but says nothing about what really constitues a "textmode". Textmode means adding line termination according to the platform definitions. However, in the case of Cygwin, I believe we are supposed to honor the mode of the filesystem as much as possible, which means sometimes line termination has CRs and sometimes it doesn't. One thing is for sure: reading script files directly must remove CRs. Everthing else is up for discussion :) I'm going to experiment with Corinna's idea and see what happens first. If that doesn't work, I'll have to continue my analysis of what the code does with those opened files. > cheers, > DaveK -- Peter A. Castro or "Cats are just autistic Dogs" -- Dr. Tony Attwood