bash CRLF problems (I have read the recent announcement)

Wilks, Dan Dan_Wilks@intuit.com
Tue Dec 5 01:01:00 GMT 2006


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.

I don't know if this helps you or not, but I get slightly different
output, consistent with what I believe you expected.  igncr will indeed
eat the \r from the `cat...` (thanks Eric once again).  Unfortunately
you're still left with the trailing \r from the last cat.

dwilks@dwilks:~% sh foo2.sh
8010.bar^M

dwilks@dwilks:~% sh --version
GNU bash, version 3.2.5(7)-release (i686-pc-cygwin)
Copyright (C) 2005 Free Software Foundation, Inc.

dwilks@dwilks:~% echo $SHELLOPTS
braceexpand:emacs:hashall:histexpand:history:igncr:interactive-comments:
monitor

But as was recently pointed out on the list, echo -n would suppress the
final \r in your test case.

Dan

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



More information about the Cygwin mailing list