Skip to content
Browse files

Handle args to proc.

:redirect-err,
:env,
:dir
  • Loading branch information...
1 parent eac06c9 commit b1830900cc3659df3260c181f883ac8e6779305c @Raynes committed Sep 24, 2012
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/conch/sh.clj
View
16 src/conch/sh.clj
@@ -4,6 +4,9 @@
[clojure.string :as string]
[useful.seq :as seq]))
+(defprotocol FeedIn
+ (feed [this]))
+
(defn char-seq [reader]
(map char (take-while #(not= % -1) (repeatedly #(.read reader)))))
@@ -25,8 +28,17 @@
(buffer-stream (k proc) (:buffer options))
(conch/stream-to-string proc k)))
+(defn add-proc-args [args options]
+ (if (seq options)
+ (apply concat args
+ (select-keys options
+ [:redirect-err
+ :env
+ :dir]))
+ args))
+
(defn run-command [name args options]
- (let [proc (apply conch/proc name args)
+ (let [proc (apply conch/proc name (add-proc-args args options))
{:keys [buffer out in err]} options]
(when in (conch/feed-from-string proc (:in proc)))
(when out (callback out buffer :out proc))
@@ -42,7 +54,7 @@
(defn execute [name & args]
(let [end (last args)
- options (and (map? end) end)
+ options (when (map? end) end)
args (if options (drop-last args) args)]
(if (:background options)
(future (run-command name args options))

0 comments on commit b183090

Please sign in to comment.
Something went wrong with that request. Please try again.