xref: /freebsd/contrib/one-true-awk/bugs-fixed/ofs-rebuild.awk (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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