Bug 150698

Summary: Awk does not honor the FIELDWIDTHS variable
Product: Red Hat Enterprise Linux 3 Reporter: Jenny Williams <jennyw>
Component: gawkAssignee: Miloslav Trmač <mitr>
Status: CLOSED NOTABUG QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
URL: http://www.unc.edu/~jennyw/Awk_Bug/Awk_3.1.1_bug.txt
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-03-14 17:16:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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):
gawk-3.1.1-9

How reproducible:
Always

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}'
3.
  

Actual Results:  >1234567
>
>

Expected Results:  >1
>2345

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}'
Thanks.

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'