Posted to tcl by venks at Sun Oct 15 19:29:06 GMT 2017view raw

  1. 1.
  2. set fi [open "|$args"]
  3. puts stderr <<<<[read $fi]>>>>
  4. close $fi
  5.  
  6. 2.
  7. set fi [open "|$args"]
  8. chan configure $fi -blocking 0 -buffering line -translation binary
  9. chan event $fi readable [list [info coroutine] line]
  10. set linum 0
  11. while {1} {
  12. set r [yield]
  13. if {[set r [gets $fi line]] < 0} {
  14. l Finished after $linum lines ($r)
  15. break
  16. }
  17. incr linum
  18. puts $fo $line
  19. }
  20. close $fi
  21.  
  22. 1 gives me 10 lines. 2 gives me 6 lines consistently. What am I missing?
  23.