\r in variables and test

Christopher Faylor cgf-use-the-mailinglist-please@cygwin.com
Sun Apr 22 18:52:00 GMT 2007

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


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/

More information about the Cygwin mailing list