# HG changeset patch # User Steve Losh # Date 1617927593 14400 # Node ID f56991dfcaea6d33e4c2d22347d502927a1cc590 # Parent 38a1fbc6688ee543249731ed30268685efe834a2 Add (sh … :result-type 'vector) diff -r 38a1fbc6688e -r f56991dfcaea losh.asd --- a/losh.asd Mon Nov 09 21:51:32 2020 -0400 +++ b/losh.asd Thu Apr 08 20:19:53 2021 -0400 @@ -12,6 +12,7 @@ :depends-on (:iterate :cl-ppcre :external-program + :flexi-streams #+sbcl :sb-sprof) :serial t diff -r 38a1fbc6688e -r f56991dfcaea package.lisp --- a/package.lisp Mon Nov 09 21:51:32 2020 -0400 +++ b/package.lisp Thu Apr 08 20:19:53 2021 -0400 @@ -78,6 +78,7 @@ :hset-map! :hset-reduce)) + (defpackage :losh.io (:use :cl :iterate :losh.quickutils) (:documentation "Utilities for input/output/reading/etc.") diff -r 38a1fbc6688e -r f56991dfcaea src/shell.lisp --- a/src/shell.lisp Mon Nov 09 21:51:32 2020 -0400 +++ b/src/shell.lisp Thu Apr 08 20:19:53 2021 -0400 @@ -19,6 +19,7 @@ * `stream`: output will be returned as a character stream. * `string`: all output will be gathered up and returned as a single string. * `list`: all output will be gathered up and returned as a list of lines. + * `vector`: all output will be gathered up and returned as a vector of octets. If `wait` is `nil`, the only acceptable values for `result-type` are `null` and `stream`. @@ -29,6 +30,7 @@ ((cons string list))) (ctypecase input (string (setf input (make-string-input-stream input))) + (vector (setf input (flexi-streams:make-in-memory-input-stream input))) (stream) (null)) (when (not wait) @@ -37,9 +39,11 @@ (let* ((out (if wait ; why is every external programming running facility a goddamn mess? (ecase result-type ((string stream list) (make-string-output-stream)) + (vector (flexi-streams:make-in-memory-output-stream)) (null nil)) (ecase result-type ((string list) (make-string-output-stream)) + (vector (flexi-streams:make-in-memory-output-stream)) (stream :stream) (null nil)))) (result (multiple-value-list @@ -56,6 +60,7 @@ (null nil) (stream (output-stream)) (string (get-output-stream-string out)) + (vector (flexi-streams:get-output-stream-sequence out)) (list (iterate (for line :in-stream (output-stream) :using #'read-line) (collect line)))) result)))))