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]

Re: bash CRLF problems (I have read the recent announcement)


Kevin Layer wrote:
I'm really perplexed by the following behavior:

rfr@mad64 ~
$ cat -v foo1.sh
echo 8010 > foo1.out

rfr@mad64 ~
$ cat -v foo2.sh
sh foo1.sh
version=`cat foo1.out`
echo ${version}.bar > foo2.out
cat -v foo2.out

rfr@mad64 ~
$ sh foo2.sh
8010^M.bar^M

rfr@mad64 ~
$ mount
C:\cygwin\bin on /usr/bin type system (textmode)
C:\cygwin\lib on /usr/lib type system (textmode)
C:\cygwin on / type system (textmode)
c: on /c type system (textmode)
z: on /z type system (textmode)

rfr@mad64 ~
$


The (real) scripts involved run on non-Windows platforms, so putting in `d2u' isn't an option. I'd rather not resort to `tr' either, since I have a large number of places to fix. Large.

The bug, IMO, is the assigment to version of `cat foo1.out` contains a
^M.  I'm on a text mount, so this is counter to what I thought would
happen.


Time to adjust your expectations. ;-)  Text mounts write CRNL as EOLs
for all files that are not explicitly opened as binary (or text for
that matter).  Text mounts remove the CR from EOLs read from files that
are not explicitly opened as binary (or text).  'cat' explicitly opens
the file as binary.  If you need it to work otherwise, write a simple
wrapper.  Or just do the easy thing and change your mode to 'binary'
and run 'd2u' on your local versions of the scripts.  This is most
compatible with the majority of "non-Windows" platforms. ;-)



--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746

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