This is the mail archive of the
mailing list for the Cygwin project.
Re: Problems with line endings for shell scripts
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:
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple