This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bash 3.1.17(8): Scripts on textmode mount get problems with CR characters


For various reasons (like various revision control systems), as
described by others elsewhere, some of us prefer to follow the Windows
standard of text file lines ending in CRLF when working on windows.

It has been one of the main strengths of Cygwin tools, that all of them
understood this.

With release 3.1.8 of Bash, however, it no longer understands Windows
conventions.

In order to tell Bash to understand CRLF, instructions say, I should
"just" mount the drive as "textmode", and all will be fine and work as
before.

However, I found that this instruction does not work, because textmode
makes ordinary scripts fail. I have mounted my /cygdrive and /home
directories as textmode:

bash-3.1$ mount
C:\cygwin\usr\X11R6\lib\X11\fonts on /usr/X11R6/lib/X11/fonts type
system (binmo
de)
C:\cygwin\home on /home type system (textmode)
C:\cygwin\bin on /usr/bin type system (binmode)
C:\cygwin\lib on /usr/lib type system (binmode)
C:\cygwin on / type system (binmode)
c: on /cygdrive/c type system (textmode,noumount)
d: on /cygdrive/d type system (textmode,noumount)
e: on /cygdrive/e type system (textmode,noumount)

Now define this shell function:

check() {
( cd $1
  echo "ABC" > f.txt
  F=`cat f.txt`

  if [ "$F" != "ABC" ] ; then
    echo "Bash is broken in $1"
  else
    echo "Bash works in $1"
  fi
  rm f.txt
)
}

Now execute these calls:

check /home/pmb
check C:/Temp
check /tmp

I get:

Bash is broken in /home/pmb
Bash is broken in C:/Temp
Bash works in /tmp

With the previous version of bash all of these worked correctly.

The reason is, that cat seems to pick up the \r character - it is not
treated as whitespace, and so the result string is no longer identical
to "ABC".

I tried setting $IFS, but I could not make that change the behaviour -
maybe I just lack instructions on how to get these characters into IFS.

Since the above worked in previous versions, and since the above works
on Linux, etc. I would tend to regard it as a regression that scripts do
not work on textmode mounts, particularly since the new bash forces me
to use textmode mounts.

Or have I overlooked something?

- Peter


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]