Bug 15886 - awk: improperly initialised field reference
Summary: awk: improperly initialised field reference
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: 1.35.x
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-10 16:10 UTC by ocbb23b
Modified: 2023-12-12 13:10 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ocbb23b 2023-12-10 16:10:57 UTC
root@clean2305:~# (echo a 1 ; echo b ) | awk '$2 != 0'
a 1
b
root@clean2305:~# (echo a ; echo b) | awk '$2 != 0'
b
root@clean2305:~# (echo a) | awk '$2 != 0'

BusyBox v1.36.1 (2023-10-09 21:45:35 UTC) multi-call binary.
Embedded in OpenWrt 23.05.0

Same problem also seen in 21.02 versions of OpenWrt


I get the correct expected output from Ubuntu gawk and Debian mawk
will@dev:~$ (echo a ; echo b) | awk '$3 != 0'
a
b
Comment 1 ocbb23b 2023-12-12 12:23:46 UTC
root@clean2305:~# (echo a; echo b) | awk 'BEGIN {ignore=$1} $2 != 0'
b
root@clean2305:~# (echo a; echo b) | awk 'BEGIN {ignore=$4} $2 != 0'
a
b
root@clean2305:~#


This is another example of the problem.  Note that if we reference $4, then the initialisation is done right for the first line