freebsd-nq/contrib/one-true-awk/bugs-fixed/ofs-rebuild.awk
Warner Losh b525355729 Merge from upstream at 4189ef5d from https://github.com/onetrueawk/awk.git
Note: this backs out a number of changes we've made to awk because
they aren't upstream, but are on the vendor branch. Those will be
reapplied. svn makes it needlessly difficult to know which ones, but
at least r315426, r301289, and maybe r301691, though there may be
others too. None of these are critical, so bisecting through this
point is safe for all but awk regression tests :).
2019-06-02 16:25:07 +00:00

18 lines
465 B
Awk

# The bug here is that nawk should use the value of OFS that
# was current when $0 became invalid to rebuild the record.
BEGIN {
OFS = ":"
$0 = "a b c d e f g"
$3 = "3333"
# Conceptually, $0 should now be "a:b:3333:d:e:f:g"
# Change OFS after (conceptually) rebuilding the record
OFS = "<>"
# Unmodifed nawk prints "a<>b<>3333<>d<>e<>f<>g" because
# it delays rebuilding $0 until it's needed, and then it uses
# the current value of OFS. Oops.
print
}