Fix process spawning to accept any ~A formattable args.

This commit is contained in:
Dominik Pantůček 2023-04-16 16:42:36 +02:00
parent 111fb10229
commit 57c8b7321d

View file

@ -36,7 +36,8 @@
(import scheme
(chicken base)
(chicken io)
(chicken process))
(chicken process)
(chicken format))
;; If given string begins with UTF-8 BOM, it is removed.
(define (remove-optional-bom str)
@ -59,7 +60,11 @@
;; Very simple shell command wrapper that returns lines produced by
;; given command. Dangerous - performs no argument escaping!
(define (get-process-output-lines cmd . args)
(let-values (((stdout stdin pid stderr) (process* cmd args)))
(let-values (((stdout stdin pid stderr)
(process* cmd
(map (lambda (x)
(format "~A" x))
args))))
(close-output-port stdin)
(let ((result (read-lines stdout)))
(let-values (((a b c) (process-wait pid)))