[Bug 180328] awk(1) fails to treat var as integer
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Sat Sep 5 18:35:36 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=180328
Jason W. Bacon <jwb at freebsd.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwb at freebsd.org
--- Comment #4 from Jason W. Bacon <jwb at freebsd.org> ---
I ran into something similar, also solved using
if ( var1 + 0 < var2 )
For data read using getline, the behavior differs from mawk and gawk from
ports. I'm not sure if this should be regarded as a bug, but it should at
least be documented.
Here's a minimal test case:
BEGIN {
x="10"
y="9"
printf("%s\n", x < y); # Always 1
x=10
y=9
printf("%s\n", x < y); # Always 0
getline x < "xy.txt"
getline y < "xy.txt"
printf("%s %s\n", x, y); # Prove we're using values from getline
printf("%s\n", x < y); # awk 1, mawk and gawk 0
}
xy.txt:
11
8
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list