delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/10/31/00:34:15

From: earnie_boyd AT yahoo DOT com (Earnie Boyd)
Subject: Re: When is \n converted to \r\n? and why?
31 Oct 1998 00:34:15 -0800 :
Message-ID: <19981030020029.5367.rocketmail.cygnus.gnu-win32@send102.yahoomail.com>
Reply-To: earnie_boyd AT yahoo DOT com
Mime-Version: 1.0
To: Urban Widmark <urban AT svenskatest DOT se>, gnu-win32 AT cygnus DOT com
Cc: noer AT cygnus DOT com, cgf AT cygnus DOT com

---Urban Widmark <urban AT svenskatest DOT se> wrote:
>
> (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:
> 

Actually, the translation is done at the time of read.  The \r is
removed when processing in text mode and the read would return 2 even
though 3 was actully read from disk.

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

Well, another improperly ported utility.  `tr' should open it's input
and output in binary mode; obviously from this example it isn't.

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

Well, you are at the mercy of the filesystem and text mode processing
will prefix a \r to every \n.  This is only a problem if the programs
are not properly ported.

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

Actually, I'd be in favor of not having either if that meant getting
properly ported code.  I wonder if we could get this resolved prior to
the b20 release?

==
-                  \\||//
-------------o0O0--Earnie--0O0o--------------
--          earnie_boyd AT yahoo DOT com          --
-- http://www.freeyellow.com/members5/gw32 --
----------------ooo0O--O0ooo-----------------

PS: Newbie's, you should visit my page.
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019