Bug 150698 - Awk does not honor the FIELDWIDTHS variable
Summary: Awk does not honor the FIELDWIDTHS variable
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gawk
Version: 3.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Miloslav Trmač
QA Contact: Brock Organ
URL: http://www.unc.edu/~jennyw/Awk_Bug/Aw...
Depends On:
TreeView+ depends on / blocked
Reported: 2005-03-09 19:38 UTC by Jenny Williams
Modified: 2007-11-30 22:07 UTC (History)
0 users

Clone Of:
Last Closed: 2005-03-14 17:16:38 UTC

Attachments (Terms of Use)

Description Jenny Williams 2005-03-09 19:38:13 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113

Description of problem:
Awk from RHN for RHEL 3.0 does not honor the FIELDWIDTHS variable.  Instead of breaking down an item into its atomic pieces to be counted out as described under the FIELDWIDTHS topic for man awk, it continues to behave as if FS=" " were still in effect, which is a setting that is supposed to be overridden when the FIELDWIDTHS variable is used.

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

How reproducible:

Steps to Reproduce:
1.echo 1234567 | awk -v FIELDWIDTHS="1 4 1" '{print $1}'
2.echo 1234567 | awk -v FIELDWIDTHS="1 4 1" '{print $2}'

Actual Results:  >1234567

Expected Results:  >1

Additional info:

Comment 1 Miloslav Trmač 2005-03-14 00:05:44 UTC
This works fine for me; please append the output of the following commands:
        which awk
        rpm -V gawk
        echo 1234567 | awk -W lint -v FIELDWIDTHS="1 4 1" '{print $2}'

Comment 2 Jenny Williams 2005-03-14 17:16:38 UTC
This ended up being an issue whith whether or not POSIX compliance was in effect.  
The POSIXLY_CORRECT variable was set on my environment to 1.
This version of gawk honors that variable to toggle POSIX compliance
in the manner described in man gawk .  The older version I was comparing it
against did not behave this way.
Thank you for your time on this issue.
The hint was as follows:
$ echo 1234567 | awk -W lint -v FIELDWIDTHS="1 4 1" '{print $2}'
$ awk: warning: `FIELDWIDTHS' is a gawk extension
$ awk: warning: environment variable `POSIXLY_CORRECT' set: turning on `--posix'

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