[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: drain-input
From: |
Gary Houston |
Subject: |
Re: drain-input |
Date: |
4 Sep 2001 21:34:00 -0000 |
> From: Neil Jerram <address@hidden>
> Date: 27 Aug 2001 10:24:21 +0100
>
> Here's a procedure that does what I expected `drain-input' to be. I
> use it often in connection with `open-input-pipe':
>
> (define (drain-output port)
> (let loop ((chars '())
> (next (read-char port)))
> (if (eof-object? next)
> (list->string (reverse! chars))
> (loop (cons next chars)
> (read-char port)))))
>
> For example...
>
> (define (texinfo->info str)
> (let* ((tmp (mkstemp! (string-copy "/tmp/guile-makeinfo-XXXXXX")))
> (tmpfn (port-filename tmp)))
> (display str tmp)
> (force-output tmp)
> (close-port tmp)
> (let* ((pipe (open-input-pipe (string-append "makeinfo"
> " --no-headers"
> " --force"
> " -o - "
> tmpfn)))
> (infostr (drain-output pipe)))
> (close-pipe pipe)
> (delete-file tmpfn)
> infostr)))
>
> Perhaps it would be worth adding `drain-output' to (ice-9 popen) ?
It's probably not a good idea to extend (ice-9 popen), since it's just
a backwards compatibility module.
It would also be worth checking whether any of the scsh interfaces for
collecting output would be suitable.
- Re: drain-input,
Gary Houston <=