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: <20100916092458 DOT GB15121 AT calimero DOT vinschen DOT de> Date: Fri, 17 Sep 2010 22:30:05 -0400 Message-ID: Subject: Re: awk gsub problem From: Lee To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , 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