Re: How to avoid new line from stream

Jean Louis <[email protected]> Sat, 4 Aug 2018 12:43:40 +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.

I just found out it is not handling complex
commands with arguments like this below. I know
that run-program requires arguments extra.

(defun gpg-decrypt (string &key homedir)
  (let ((command
          (format nil
                  "gpg -d --no-permission-warning --trust-model always --yes --homedir ~a"
                  homedir)))
    (slurp-stream-io-command command string)))
                  
Basically, I am using this one as working:

(defun slurp-stream-io-command (command string)
  "Returns the output of a command to which string has been fed, very
usable for markdown, emacs Org mode processing and similar"
  (with-input-from-string (in string)
    (uiop:run-program command :input in :output :string :ignore-error-status t)))

however, loading of ASDF and UIOP is taking time,
which I try to avoid. That is why I am looking
into pure CLISP way of doing the same.

Do you think I should just take first part before
space as the command, and arguments as the rest
and feed to CLISP's run-program?

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