xref: /illumos-gate/usr/src/test/util-tests/tests/awk/bugs-fixed/ofs-rebuild.awk (revision 45ede40b2394db7967e59f19288fae9b62efd4aa)
1# The bug here is that nawk should use the value of OFS that
2# was current when $0 became invalid to rebuild the record.
3
4BEGIN {
5	OFS = ":"
6	$0 = "a b c d e f g"
7	$3 = "3333"
8	# Conceptually, $0 should now be "a:b:3333:d:e:f:g"
9
10	# Change OFS after (conceptually) rebuilding the record
11	OFS = "<>"
12
13	# Unmodifed nawk prints "a<>b<>3333<>d<>e<>f<>g" because
14	# it delays rebuilding $0 until it's needed, and then it uses
15	# the current value of OFS. Oops.
16	print
17}
18