xref: /illumos-gate/usr/src/test/util-tests/tests/awk/bugs-fixed/ofs-rebuild.awk (revision d8109ce4330e1b8ad6c29f9fccacec969066bb9d)
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