<div dir="ltr">You can also simplify the reading in part with port->lines<div><br></div><div><div>#lang racket</div><div>(define-values (in out) (make-pipe))</div><div>(parameterize ([current-output-port out])</div><div>
(system (format "find . ~a ~a" "-name \"*.c\"" "-print"))</div><div> (close-output-port (current-output-port))</div><div> (port->lines in))</div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Oct 16, 2013 at 1:36 PM, David Vanderson <span dir="ltr"><<a href="mailto:david.vanderson@gmail.com" target="_blank">david.vanderson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On 10/16/2013 12:35 PM, Vlad Kozin wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
assuming I have a number of .c files I expect "find" to write corresponding lines to (current-output-port). I want to collect them in a list. Here's a solution I thought would work:<br>
------------------------------<u></u>------<br>
(define-values (in out) (make-pipe))<br>
(parameterize ((current-output-port out))<br>
(system (format "find . ~a ~a" "-name \"*.c\"" "-print"))<br>
(for/list ((line (in-lines in)))<br>
line))<br>
<br>
It doesn't. It blocks expecting input.<br>
<br></div><div class="im">
Blocks again. Am I not getting EOF here?<br>
<br>
</div></blockquote>
I think you are on the right track here. You need to close the output port on the pipe so "in-lines" stops reading:<div class="im"><br>
<br>
(define-values (in out) (make-pipe))<br>
(parameterize ((current-output-port out))<br>
(system (format "find . ~a ~a" "-name \"*.c\"" "-print"))<br></div>
(close-output-port (current-output-port))<div class="im"><br>
(for/list ((line (in-lines in)))<br>
line))<br>
<br></div>
Does that make sense?<br>
<br>
Alternatively you can rearrange your last example:<br>
<br>
(define str (with-output-to-string<div class="im"><br>
(lambda ()<br>
(system (format "find . ~a ~a" "-name \"*.c\"" "-print")))))<br></div>
(for/list ((line (in-lines (open-input-string str))))<br>
line)<br>
<br>
Thanks,<br>
Dave<div class="HOEnZb"><div class="h5"><br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a><br>
</div></div></blockquote></div><br></div>