delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/09/17/22:30:18

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,TW_VM,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <20100916092458.GB15121@calimero.vinschen.de>
References: <AANLkTikzGH8GUZ5ZUytSJShfYE=KMyphyue83Q8XMm4- AT mail DOT gmail DOT com> <20100916092458 DOT GB15121 AT calimero DOT vinschen DOT de>
Date: Fri, 17 Sep 2010 22:30:05 -0400
Message-ID: <AANLkTimwcbmxMtfZWbkztef+fxQfKtoM9CsFOd38E2a3@mail.gmail.com>
Subject: Re: awk gsub problem
From: Lee <ler762 AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
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 9/16/10, Corinna Vinschen wrote:
> On Sep 15 18:30, Lee wrote:
>> I don't know if this is just a problem with the cygwin version of awk,
>> me misunderstanding something or what, but it looks like gsub isn't
>> working correctly in awk:
>> $ sh /tmp/test.awk
>> s= ::0::  should = ::S0::
>>
>> $ cat /tmp/test.awk
>> awk '
>> BEGIN {
>>   s="Serial0"
>>   gsub("[a-z]","",s)
>>   printf("s= ::%s::  should = ::S0::\n", s)
>>   exit
>> } '
>>
>>
>> I also tried it with IGNORECASE=0 and with "awk --traditional" - same
>> results.
>>
>> $ which awk
>> /usr/bin/awk
>>
>> $ awk --version
>> GNU Awk 3.1.8
>
> Works fine for me:
>
>   $ uname -a
>   CYGWIN_NT-6.1 vmbert7 1.7.7(0.230/5/3) 2010-08-31 09:58 i686 Cygwin
>   $ gawk --version
>   GNU Awk 3.1.8
>   Copyright (C) 1989, 1991-2010 Free Software Foundation.
>   [...]
>   $ sh //calimero/corinna/test.awk
>   s= ::S0::  should = ::S0::
>   $

Thanks for the reply.  If it works for you, doesn't work on my home or
work computer & upgrading doesn't fix it ... it's probably something I
did.  Which it was - I had this bit in my c:\cygwin\cygwin.bat file:
@rem set LANG envar for proper display
@rem ref: http://cygwin.com/cygwin-ug-net/setup-locale.html
set LANG=en_US.UTF-8

Comment out the 'set LANG=" and gsub works fine:
$ echo $LANG
C.UTF-8

$ sh /tmp/test.awk
s= ::S0::  should = ::S0::

$ export LANG=en_US.UTF-8

$ sh /tmp/test.awk
s= ::0::  should = ::S0::

So awk gsub works for me again - thank you!

Just out of curiosity, why would setting LANG to en_US break
case-sensitivity in gsub?

Regards,
Lee

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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