Re: How to avoid new line from stream

Jean Louis <[email protected]> Sat, 4 Aug 2018 10:37:36 +0200
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
On Sat, Aug 04, 2018 at 03:11:00AM +0200, Max Zettlmeißl wrote:
> On Fri, Aug 3, 2018 at 2:38 PM, Jean Louis <[email protected]> wrote:
> > that one blocks forever too. I get the idea, and I
> > just cannot find working example.
> >
> > I would like to learn how to use it with
> > run-program.
> 
> (defun slurp-stream-io-command (command input)
>   (with-open-stream (stream (run-program command
>                                          :input :stream
>                                          :output :stream))
>     (princ input stream)
>     (close (two-way-stream-output-stream stream))
>     (with-output-to-string (output)
>       (loop
>          for c = (read-char stream nil)
>          while c
>          do (write-char c output)))))
> 
> This should be a good solution to your problem as you described it.
> It finishes the input with an EOF for the programs that need it and
> and handles empty program output.

Very nice. Thank you for good example.

Jean

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list