This is the mail archive of the cygwin@sourceware.cygnus.com 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]

When is \n converted to \r\n? and why?


(using cygwin32 19.3 & 19.1?)

If I create a small example file:

$ echo a > xx
$ ls -l xx
-rw-r--r--   1 544      everyone        3 Oct 28 15:43 xx

it will contain "a\r\n" since I use the default (non-binary mounts)

But if I do:
$ echo a | wc -c
      2

I get only 2 chars ... ok, so the translation is done when writing to
disk. Then something like this will fail:

$ echo a | tr -d '\r' > yy
$ ls -l yy
-rw-r--r--   1 544      everyone        3 Oct 28 15:48 yy

So how am I supposed to remove the \r from the echo output?  Well, I know
non-cygwin ways to remove the \r, the issue is if this is a tr bug, a
cygwin conversion bug or ...


It's also strange that writing to a pipe is different from writing to
disk, that seems very non-unix'ish. I think it would be better if
conversion could be toggled by changing an environment variable, it should
not depend on the destination of my output.

An environment variable would be better than a registry entry, since it's
hard to write "non-conversion" shell scripts that can be run on other
machines if they depend on a registry entry ... Also some scripts may need
the feature turned on, others off.

/Urban, who knows next to nothing about windows .dlls

---
Urban Widmark                           urban@svenskatest.se
Svenska Test AB                         +46 90 71 71 23

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


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