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 Reply-To: From: "Ross Boulet" To: "'David Mastronarde'" , Subject: RE: 1.5.9: tcsh 6.12.00 parses scripts wrong with DOS line endings Date: Sat, 10 Apr 2004 04:32:54 -0500 Message-ID: <000001c41ede$d5e98340$6400000a@RossLap> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" In-Reply-To: X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id i3A9XjUa006900 > -----Original Message----- > From: cygwin-owner On Behalf Of David Mastronarde > > When csh scripts have DOS line endings, tcsh 6.12.00 > sometimes parses them > incorrectly. This seems to happen with scripts that have > while loops, > once the scripts get big enough. Converting the script to unix line > endings fixes the problem. > > The attached script, cshbug, is about as small as it can be > to show the > problem. It needs to be run with a valid argument, in my case > cshbug -inst /usr/local/IMOD > > The standard error output is: > =: Command not found. > > The attached file bugout2 is the output from > csh -v cshbug -inst /usr/local/IMOD > > After the first trip through the while loop, it jumps back up to the > middle of a line before the loop: > = "unsigned int" > > If the variable setting section of the script is made > smaller, such as > by removing the first 13 lines, the problem goes away. > > This problem has been present for the past year at least. > > David Mastronarde > Boulder Laboratory for 3-D Electron Microscopy of Cells > FWIW, looking at your cshbug.txt file, I see that the line endings are unusual. A normal DOS line ending is a combination. Your file seems to have an extra at the end of each line. Each line ends with . My guess is when tcsh is processing the script, it does not count the extra characters, so when it loops, its offset into the script is off by a number of characters equivalent to the number of extra s. In other words, the while statement in the script is on line 101. When it loops, tcsh is jumping to a location in the file calculated by assuming the size of the lines plus a two character line ending, not three. Therefore, the jump location is off by the number of bytes (101) its trying to get to. The script is 190 lines long. If you run dos2unix on the file, the resulting file is 380 bytes smaller, having dropped two per line. Running unix2dos on the result increases the file size by only 190 (one per line). I'd be curious whether this resulting file with "normal" DOS line endings works correctly for you. I don't know if tcsh should handle the extra 's or not. But perhaps my observation will at least narrow down where to look. Ross -- 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/