Re: How to avoid new line from stream

Max Zettlmeißl via clisp-list <[email protected]> Sat, 4 Aug 2018 03:11:00 +0200
Newsgroups gmane.lisp.clisp.general
Message-ID <CACjvM=ezFDH_gyuK80wP2gj+ymLapdnv94uQ4NQM1ZPfJ82W-A@mail.gmail.com>
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.

------------------------------------------------------------------------------
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