delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/04/22/14:53:11

X-Spam-Check-By: sourceware.org
Date: Sun, 22 Apr 2007 14:52:52 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: \r in variables and test
Message-ID: <20070422185252.GA32311@trixie.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20070422170609 DOT GV7781 AT interface DOT famille DOT thibault DOT fr> <f0g6n4$511$1 AT sea DOT gmane DOT org>
Mime-Version: 1.0
In-Reply-To: <f0g6n4$511$1@sea.gmane.org>
User-Agent: Mutt/1.5.11
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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

On Sun, Apr 22, 2007 at 06:40:29PM +0100, Michael Hoffman wrote:
>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.

Another one is

[[ "$foo" == True* ]]

cgf

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