Posted to tcl by msiism at Wed Jan 27 13:05:38 GMT 2021view raw
- #!/usr/bin/env tclsh
- set find_done 0
- set find_path $env(HOME)
- proc _pipe_chunk {ichan} {
- global find_done
- set chunk {}
- # Read a single character from $ichan.
- # See whether it's NUL.
- # If not, append it to $chunk.
- # Return $chunk when it's complete (NUL encountered).
- # Handle occurrence of EOF while doing this.
- while {true} {
- set char [read $ichan 1]
- if {[eof $ichan]} {
- close $ichan
- set find_done 1
- break
- } elseif {$char == "\0"} {
- puts $chunk
- break
- } else {
- set chunk ${chunk}${char}
- }
- }
- }
- set find_out [open "| find $find_path -type f -print0" r]
- chan event $find_out readable [list _pipe_chunk $find_out]
- #chan configure $find_out -buffering line
- vwait $find_done
Comments
Posted by msiism at Wed Jan 27 13:36:26 GMT 2021 [text] [code]
s/vwait $find_done/vwait find_done