|
From: | Manuel Collado |
Subject: | Re: gawk bug - 'is equal' is faulty for string |
Date: | Mon, 27 Jan 2020 15:32:19 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
El 27/01/2020 a las 14:28, Jérôme Jargot escribió:
Hello, This is not the last gawk version and I think I must be mistaken because the == is very likely not buggy for strings. Still I do not understand my mistake, so I submit a bug report. *TESTS: 'is equal' is faulty for string => 2 lines printed instead of 1* # printf "'a', '7.1'\n'a', '7.2'\n'a', '7.3'\n'a', '7.10'\n" "" | LC_ALL=C gawk --field-separator \' '$4==cversion {print}' cversion=7.10 'a', '7.1' 'a', '7.10' # printf "'a', '7.1'\n'a', '7.2'\n'a', '7.3'\n'a', '7.10'\n" "" | LC_ALL=C gawk --field-separator \' '$4==cversion {print}' cversion=7.1 'a', '7.1' 'a', '7.10'
I think this is the expected result in both cases. The "$4==cversion" comparison is a numeric one, because both $4 and cversion values come from input data and look as numbers.
Please search for "numeric string" or "strnum" in the gawk manual. Hope this helps. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
[Prev in Thread] | Current Thread | [Next in Thread] |