X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: Michael Hoffman <b3i4old02@sneakemail.com>
Subject:  Re: \r in variables and test
Date:  Sun, 22 Apr 2007 18:40:29 +0100
Lines: 22
Message-ID: <f0g6n4$511$1@sea.gmane.org>
References:  <20070422170609.GV7781@interface.famille.thibault.fr>
Mime-Version:  1.0
Content-Type:  text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding:  7bit
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
In-Reply-To: <20070422170609.GV7781@interface.famille.thibault.fr>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Samuel Thibault wrote:
> Hi,
> 
> In a ./configure script, I call a test program (native python, actually)
> that outputs "True\r\n" and I put this result in variable foo. The
> problem is that [ "$foo" = True ] doesn't return true because foo
> actually contains True\r, not True.
> 
> Is there a nice way around this?

You haven't provided sufficient information about which bits you are 
willing to change.

Some things you could do are:

* use Cygwin Python
* change the Python script to output \n instead of \r\n
* [ $foo = $'True\r' ]
* [ ${foo/%$'\r'/} = True ]

The last has the advantage that it will work even if the script outputs 
only "True\n" instead of \r\n.


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

