I was looking at how different projects on quicklisp use uiop:run-program and came across this snippet in common-doc:
(defmethod expand-macro ((plot gnuplot))
"Take the gnuplot source code from the children and the image name, render it
with gnuplot into an image."
(let* ((pathname (absolute-path (image-path plot)))
;; The gnuplot commands
(text (text (first (children plot))))
;; The gnuplot commands to set output format, file etc.
(input (format nil "set term pngcairo; set output ~S; ~A~%"
(namestring pathname)
text))
;; The gnuplot command
(command "gnuplot"))
;; Run
(handler-case
(progn
(with-input-from-string (stream input)
(uiop:run-program command :input stream))
(make-image (namestring (relativize-pathname pathname))))
(t ()
(make-text "gnuplot error.")))))
I wanted to let you know that passing input to uiop:run-program through a stream, especially one that isn't a file stream, is not very portable. But you can also pass strings directly (that's far more portable because it internally uses a file). So e.g.
Hi,
I was looking at how different projects on quicklisp use
uiop:run-program
and came across this snippet in common-doc:I wanted to let you know that passing input to
uiop:run-program
through a stream, especially one that isn't a file stream, is not very portable. But you can also pass strings directly (that's far more portable because it internally uses a file). So e.g.will print "hello, world".