Bug 147746 - awk: incorrect results when using $(NF)
Summary: awk: incorrect results when using $(NF)
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: gawk
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Brock Organ
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-02-10 21:56 UTC by Timo Lindfors
Modified: 2007-11-30 22:11 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-02-13 18:33:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Timo Lindfors 2005-02-10 21:56:49 UTC
Description of problem:

Awk in fedora core 3 seems to behave oddly. For example it fails to
run the tests in ./autogen.sh of cairo's cvs HEAD as of today. I am
not really familiar with awk but I hope the reduced testcase in 'steps
to reproduce' is enough to help you to fix this bug. I have seen no
other system return "0" but fedora core 3. (At least debian
stable/unstable, suse and redhat seem to return the correct result, "1").

Version-Release number of selected component (if applicable):

GNU Awk 3.1.3
linux 2.6.10-1.760_FC3

How reproducible:

Always

Steps to Reproduce:
1. echo -ne "2.59\n" | awk 'NR==1 { if( $(NF) >= 2.54) exit 1; exit 0;
}'; echo $?
  
Actual results:

0

Expected results:

1

Additional info:

The component is of course not "sed" but I don't know how to find out
what's the right component for awk. There could be a search form in
bugzilla that would accept name of binary and return component name.

Comment 1 Karel Zak 2005-02-13 18:33:32 UTC
Please, check your locale setting if you work with decimal point.

Tested with gawk-3.1.4d, gawk-3.1.4 (devel), gawk-3.1.3 (FC-3, RHEL-4),
gawk-3.1.0 (RHEL-2.1):

$ export LANG=en_US 
$ echo -ne "2.59\n" | awk 'NR==1 { if( $(NF) >= 2.54) exit 1; exit 0; }'; echo $? 
1

$ export LANG=cs_CZ.UTF-8 
$ echo -ne "2.59\n" | awk 'NR==1 { if( $(NF) >= 2.54) exit 1; exit 0; }'; echo $?
0



Comment 2 Timo Lindfors 2005-02-13 18:56:51 UTC
Oh, good point. Seems I need to unset some variables in my ~/.bashrc.


Note You need to log in before you can comment on or make changes to this bug.