MS-DOS CR/LF compatibility in $() and ``?

Pontus Lidman
Thu Aug 26 03:13:00 GMT 1999

It seems that when the output of a command contains MS-DOS newlines
(CR+LF), these are not stripped from the end of the output when command
substitution is done.


echo -e "test\r\n" >file
VAR=`cat file`
echo xxx${VAR}yyy

this will produce the output

which indicates that there is a newline or carriage return at the end of
the text of the variable. This is very unfortunate e.g. if the text was
supposed to be a filename because test -f "$VAR" will fail even if the
intended file exists.

Is there a way to get around this problem (Cygwin B20)?



Want to unsubscribe from this list?
Send a message to

More information about the Cygwin mailing list