delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/03/11:29:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <42779927.FF17EA38@dessent.net>
Date: Tue, 03 May 2005 08:30:47 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Re: echo "$(echo '\r')" oddity
References: <D1D50F9C5151D2119FF000104BB3F9B708E1B754 AT NL-ROT-MAIL02>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Jan Just Keijser wrote:

> I have just run into a Cygwin vs Linux oddity that I cannot explain. I've
> managed to trace the problem back to a very simple statement:
>   echo "$(echo -e '\r')" | od -x
> on my W2K Cygwin install (Cygwin1.dll 2005/04/01), this produces
>   0000000 000a
>   0000001
> On Linux, this command produces:
>   # echo "$(echo -e '\r')" | od -x
>   0000000 0a0d
>   0000002
> (which is what I'd expect).
> Also, the Cygwin command
>   echo -e '\r' | od -x
> also returns
>   0000000 0a0d
>   0000002

It appears that bash's handling of `` and $() is hardwired to do \r\n ->
\n translation.  I am not sure but that may be one of those patches that
was added to bash that makes more things work than it breaks. 

... *checks* ...

Yes indeed:

subst.c, function read_comsub() (which implements command substitution)

#ifdef __CYGWIN__
  setmode (fd, O_TEXT);    /* we don't want CR/LF, we want Unix-style */
#endif

Brian

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

- Raw text -


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