Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Reply-To: From: "Ryan Seghers" To: Subject: CR/LF translation Date: Wed, 4 Oct 2000 11:06:46 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Hi, I have a problem with end-of-line characters in a bash script. I'd appreciate any suggestions or information you can provide. In summary, I'm getting different behavior from this script based on whether I process a NT text file or a Cygwin (vim) text file. I read somewhere that Cygwin did the end-of-line character translation automatically, but apparently not. I don't have CYGWIN=binmode set. I saw an option in Cygwin's setup.exe for default file type, DOS vs Unix. I have installed both ways and seen the same behavior. I uninstalled everything using setup.exe between installs. Here's the bash script: #!bash list=`cat $1` for word in $list; do echo List item is ${word}END-OF-LINE done Here's the input file (indented) created by concatenating a file created in notepad (3 lines) onto the end of a file created with vim (3 lines) using cat: this is unix this is notepad Here's the output on my test file (indented): List item is thisEND-OF-LINE List item is isEND-OF-LINE List item is unixEND-OF-LINE END-OF-LINEs this END-OF-LINEs is END-OF-LINEs notepad So the last three lines are mangled, apparently by a carriage return character. It seems fairly clear that notepad put in a CR character which is not being stripped by cat. I can fix this with a dos2unix utility I downloaded, but it would be more convenient not to have to do this. What's wrong with my setup? Here are the relevant versions: bash 2.04-1 cygwin 1.1.4 Thanks in advance, Ryan Seghers PS. Here's a bonus question. I tried to write my own dos2unix. So I wrote a dump program in Visual C++ without any special includes or links (not linking any cygwin DLLs as far as I know). I wanted to see what the codes were for the end-of-line characters so I could strip them. When I run my dump from a NT Command Prompt on the text file, I see no difference between the first three lines and the last three lines. All the lines are terminated by a single character, int 10!? So my dump program isn't showing the CR character. Is my dump program build picking up a cygwin DLL or something? Here's the source: // // read the file // char c; while(!feof(fd)) { c = getc(fd); if (c != -1) printf("c (int) = %d\n", c); } } -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com