This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: awk gsub problem
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