X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <4B702BA9.2080703@bopp.net> Date: Mon, 08 Feb 2010 09:20:09 -0600 From: Jeremy Bopp User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Problems with line endings for shell scripts References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 On 2/8/2010 6:30 AM, Jurgen Defurne wrote: > Dear all, > > I have the following mounts on my test & verification system for Cygwin 1.7. > > C:/Documents and Settings on /home type ntfs (binary,exec) > C:/cygwin/bin on /usr/bin type ntfs (binary,auto) > C:/cygwin/lib on /usr/lib type ntfs (binary,auto) > C:/cygwin on / type ntfs (binary,auto) > C:/local on /usr/local type ntfs (binary,exec) > B: on /cygdrive/b type cifs (binary,posix=0,user,noumount,auto) > C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto) > E: on /cygdrive/e type cifs (binary,posix=0,user,noumount,auto) > H: on /cygdrive/h type netapp (binary,posix=0,user,noumount,auto) > Z: on /cygdrive/z type ntfs (binary,posix=0,user,noumount,auto) > > Today I am having a problem with running a shell script (sh/bash) > which has CRLF endings. This is already an old script and has been > much used across Cygwin 1.3, 1.5. MontaVista 4.0 and Montavista 5.0. > > After testing (because Perl does not have a problem), I found out that > there is a problem with empty lines in bash. > > Here is my test case : > > echo Line to echo > > echo Another line > > When running this, I get the output > > Line to echo > run_echo: line 2: $'\r': command not found > Another line > > I also tested it on my portable. There I do not have the problem. The main > difference between the two systems is that the OS in the first case is > 2003 Server and in the second case Windows XP. The problem is that Bash only supports Unix line endings, and your system is configured to use binary mounts which send the scripts to Bash with the Windows line endings intact. Your portable most likely has text mounts configured which strip the Windows line endings from the files on the fly as Bash reads them or is using one of the other mechanisms mentioned here: http://cygwin.com/ml/cygwin-announce/2009-07/msg00002.html -Jeremy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple