CR/LF and read is shell scripts
Fifer, Eric
EFifer@sanwaint.com
Fri Aug 18 07:39:00 GMT 2000
Eirik_Nordbrøden <eirik.nordbroden@scandpower.no> wrote:
> The script generates a temporary file by the use of the echo
> statement and later on the content is evaluated with a cat and consecutive
> read statements. The problem is that the generated file contains CRLF at
the
> end of each line, but the read statement only recognises the LF and
therefore
> adds CR to the last variable read.
The behavior of cat seems to have changed (presumably
after the textutils-2.0 upgrade on 7/8). Formerly,
it performed CR/LF mapping based on the binary/text
mode of the input file. Now it is always in binary
mode, unless you're adding numbers (or other non-verbatim
options). In these examples x has "hello\r\n":
$ od -c x
0000000 h e l l o \r \n
0000007
On binary mount:
$ cat x | od -c
0000000 h e l l o \r \n
0000007
$ cat -n x | od -c
0000000 1 \t h e l l o \r \n
0000016
On text mount:
$ cat x | od -c
0000000 h e l l o \r \n
0000007
$ cat -n x | od -c
0000000 1 \t h e l l o \n
0000015
There are old threads discussing how people disliked
the text behavior of cat. However, I think the old
behavior of cat should be restored. And, for those
who need binary behavior there is now a -B/--binary
option.
Any other opinions?
Eric Fifer
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
More information about the Cygwin
mailing list