Trouble capturing output with with-output-to-string

From: Harvey J. Stein <hjstein_at_MATH.HUJI.AC.IL>
Date: Sat, 26 Aug 1995 20:09:14 +0300

For some reason, I can capture neither the output of a running process
nor of the system call with with-output-to-string. Hear're some
examples:

hjstein:~$ snow
Welcome to the STk interpreter version 2.2 [Linux-1.X-ix86]
Copyright (C) 1993,1994,1995 Erick Gallesio - I3S - CNRS / ESSI <eg_at_unice.fr>
STk> (define foo (with-output-to-string (lambda () (format (current-output-port) "hi"))))
#[undefined]
STk> foo
"hi"
STk> (define foo (with-output-to-string (lambda () (format #t "hi"))))
#[undefined]
STk> foo
"hi"

Note that with format, outputing to both (current-output-port) and to
#t get packaged up by with-output-to-string, and passed back as a
string to the define. However, the system call doesn't seem to do
this (in the following, foobar is a file in the current directory
containing "bye\n"):

STk> (define foo (with-output-to-string (lambda () (system "cat foobar"))))
bye
#[undefined]
STk> foo
""

Note that the contents of foobar got sent to stdout, got displayed on
the screen, but didn't get captured by with-output-to-string.
Run-process behaves similarly:

STk> (define foo (with-output-to-string (lambda () (run-process "cat" "foobar" :wait #t))))
bye
#[undefined]
STk> foo
""

This is even the case if run-process is explicitly told to output to
(current-output-port):

STk> (define foo (with-output-to-string (lambda () (run-process "cat" "foobar" :output (current-output-port) :wait #t))))
bye
#[undefined]
STk> foo
""

Is this a bug, or am I losing it?

Thanks,

Dr. Harvey J. Stein
Berger Financial Research
hjstein_at_math.huji.ac.il
Received on Sat Aug 26 1995 - 19:10:01 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST