[gambit-list] Process stdout redirection

C K Kashyap ckkashyap at gmail.com
Tue Mar 20 21:03:22 EDT 2018


Thanks Adam,

I was wondering then, what would be a better way to do this -
(with-output-to-file "output.txt"
  (lambda ()
    (display
     (call-with-input-process
      program
      (lambda (port)
(read-line port #f))))))

If I understand it right, this requires an extra read and write. If Gambit
lets the port be overridden by the surrounding with-output-to-file, perhaps
the whole thing could be achieved without the extra read and write. Hence
my question was more about whether there is a problem with this approach
that I am not able to see.

Regards,
Kashyap

On Tue, Mar 20, 2018 at 5:26 PM, Adam <adam.mlmb at gmail.com> wrote:

>
>
> 2018-03-21 1:54 GMT+08:00 C K Kashyap <ckkashyap at gmail.com>:
>
>> Got it - so if I have to redirect to a file, I could do this -
>> (with-output-to-file "output.txt"
>>   (lambda ()
>>     (display
>>      (call-with-input-process
>>       program
>>       (lambda (port)
>> (read-line port #f))))))
>>
>>
>> Although, I'd like to understand why stdout-redirection: #f outputs to
>> stdout and not the current output port.
>>
>
> Stdout is the current output port of the host OS environment, so this
> argument specifies that Gambit should leave it untouched.
>
> Is that a problem?
>>
>
> That depends on you.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20180320/0c8e1f22/attachment.htm>


More information about the Gambit-list mailing list