miller/test/cases/verb-split/0009/split_1.pprint.expect
John Kerl 9910351ca1
Copy records handed to async file-writers in tee and split verbs (#1671) (#2152)
The tee verb passed the same record pointer both to its file-output
handler (which writes asynchronously on another goroutine, and whose
buffering formats like pprint/json can hold records until close) and
downstream in the verb chain, where subsequent verbs mutate records in
place. Downstream mutations could therefore leak into the tee'd output:

  mlr tee -p cat then cat -n then nothing <<EOF
  a=1,b=2
  a=3,b=4
  a=5,b=6
  EOF

emitted "n=3,a=5,b=6" for the last tee'd record, and with pprint/json
tee formats every record picked up downstream fields.

Fix: give the file-writer its own deep copy of the record. Same fix
applied to the split verb when -v (emit downstream) is used, which
shared records with downstream the same way.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-05 20:17:32 -04:00

6 lines
312 B
Text

color shape flag k index quantity rate
yellow triangle true 1 11 43.64980000 9.88700000
red square true 2 15 79.27780000 0.01300000
red circle true 3 16 13.81030000 2.90100000
red square false 4 48 77.55420000 7.46700000
purple triangle false 5 51 81.22900000 8.59100000