|
From: | Hermann Peifer |
Subject: | Re: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable |
Date: | Fri, 7 Aug 2015 18:26:12 +0200 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 2015-08-07 13:34, Aharon Robbins wrote:
Hi.Date: Thu, 6 Aug 2015 15:55:50 +0800 From: Li Chao <address@hidden> To: bug-gawk-mXXj517/address@hidden Subject: [bug-gawk] [bug report] gawk doesn???t work correctly when assign special value to variable 2) Prepare a test file cat > 1.txt << EOF 00e1 00e1 00e2 00e4 00e3 00e1_01 EOF 3) Execute following command to see the result [root]# gawk -v var="00e1" '$2==var' 1.txt 00e1 00e1 00e2 00e4 The second line should not be there. Because "00e4" is NOT equal to "00e1" obviously.They are equal numerically, and that is the kind of comparison gawk does on that data. See the link that Andy gave you.
$ gawk -v var="00e1" '$2==var{print $0, typeof(var), typeof($2)}' 1.txt 00e1 00e1 string strnum 00e2 00e4 string strnumAbove, I just gave it a try using gawk/master which says that typeof(var) is string, which in return should result into a string comparison according to the manual. So I would also expect the comparison to fail in the 2nd line:
$2 = 00e4/strnum is not string-equal with var = 00e1/string Hermann
[Prev in Thread] | Current Thread | [Next in Thread] |