Browse files

Add RUNSTRING to run /bin/sh -c 'foo' stuff.

  • Loading branch information...
xach committed Dec 5, 2011
1 parent 8581217 commit a57d57ee466e65897eab50cdd5505df7273658ac
Showing with 16 additions and 1 deletion.
  1. +13 −0 commando.lisp
  2. +3 −1 package.lisp
@@ -34,6 +34,19 @@ nonzero status, signals an error."
;; FIXME: Raise a proper condition that can be handled.
(error "Command exited with non-zero status ~D" code)))))
+(defvar *runstring-command* '("/bin/bash" "-c")
+ "The command and argument to use to run RUNSTRING shell strings.")
+(defun runstring (command &rest arguments)
+ "Run COMMAND as an argument to 'sh -c'. If there are any ARGUMENTS,
+ COMMAND is treated as a format control string and used to construct
+ the final command."
+ (when arguments
+ (setf command (apply #'format nil command
+ (mapcar #'stringify-command-argument
+ (flatten arguments)))))
+ (apply #'run (append *runstring-command* (list command))))
(defmacro with-run-output ((stream (command &rest args)) &body body)
"Bind STREAM to the output stream of COMMAND and evaluate BODY."
`(let* ((*command-output* (make-string-output-stream)))
@@ -14,8 +14,10 @@
(:export #:*command-output*
- #:*default-temporary-template*)
+ #:*default-temporary-template*
+ #:*runstring-command*)
(:export #:run
+ #:runstring

0 comments on commit a57d57e

Please sign in to comment.