Bug 15886

Summary: awk: improperly initialised field reference
Product: Busybox Reporter: ocbb23b
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.35.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

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