From db3c98585a2c0541ef2f9a0c01482e2aa5132a29 Mon Sep 17 00:00:00 2001
From: Ben Smith-Mannschott <bsmith.occs@gmail.com>
Date: Tue, 24 Aug 2010 20:20:55 +0200
Subject: [PATCH 8/8] removed c.c.shell and c.c.shell-out

Both are deprecated in 1.2 and have been replaced by
clojure.java.shell.
---
 modules/complete/pom.xml                           |   10 --
 .../main/clojure/clojure/contrib/gen_html_docs.clj |    2 -
 modules/shell-out/pom.xml                          |   16 --
 .../src/main/clojure/clojure/contrib/shell_out.clj |  149 --------------------
 modules/shell/pom.xml                              |   16 --
 .../src/main/clojure/clojure/contrib/shell.clj     |  149 --------------------
 .../test/clojure/clojure/contrib/test_shell.clj    |   41 ------
 pom.xml                                            |    2 -
 8 files changed, 0 insertions(+), 385 deletions(-)
 delete mode 100644 modules/shell-out/pom.xml
 delete mode 100644 modules/shell-out/src/main/clojure/clojure/contrib/shell_out.clj
 delete mode 100644 modules/shell/pom.xml
 delete mode 100644 modules/shell/src/main/clojure/clojure/contrib/shell.clj
 delete mode 100644 modules/shell/src/test/clojure/clojure/contrib/test_shell.clj

diff --git a/modules/complete/pom.xml b/modules/complete/pom.xml
index 9d73a61..f68e76a 100644
--- a/modules/complete/pom.xml
+++ b/modules/complete/pom.xml
@@ -306,16 +306,6 @@
     </dependency>
     <dependency>
       <groupId>org.clojure.contrib</groupId>
-      <artifactId>shell</artifactId>
-      <version>1.3.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.clojure.contrib</groupId>
-      <artifactId>shell-out</artifactId>
-      <version>1.3.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.clojure.contrib</groupId>
       <artifactId>singleton</artifactId>
       <version>1.3.0-SNAPSHOT</version>
     </dependency>
diff --git a/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj b/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
index 466c3fb..2e54aee 100644
--- a/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
+++ b/modules/gen-html-docs/src/main/clojure/clojure/contrib/gen_html_docs.clj
@@ -509,7 +509,6 @@ emits the generated HTML to the path named by path."
      'clojure.contrib.repl-utils
      'clojure.contrib.seq
      'clojure.contrib.server-socket
-     'clojure.contrib.shell
      'clojure.contrib.sql
      'clojure.contrib.stream-utils
      'clojure.contrib.string
@@ -532,7 +531,6 @@ emits the generated HTML to the path named by path."
      'clojure.contrib.test-clojure.printer
      'clojure.contrib.test-clojure.reader
      'clojure.contrib.test-clojure.sequences
-     'clojure.contrib.test-contrib.shell
      'clojure.contrib.test-contrib.string
      'clojure.contrib.zip-filter.xml
      ]))
diff --git a/modules/shell-out/pom.xml b/modules/shell-out/pom.xml
deleted file mode 100644
index 219bb2b..0000000
--- a/modules/shell-out/pom.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.clojure.contrib</groupId>
-    <artifactId>parent</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-    <relativePath>../parent</relativePath>
-  </parent>
-  <artifactId>shell-out</artifactId>
-  <dependencies>
-  </dependencies>
-</project>
\ No newline at end of file
diff --git a/modules/shell-out/src/main/clojure/clojure/contrib/shell_out.clj b/modules/shell-out/src/main/clojure/clojure/contrib/shell_out.clj
deleted file mode 100644
index 8fcd368..0000000
--- a/modules/shell-out/src/main/clojure/clojure/contrib/shell_out.clj
+++ /dev/null
@@ -1,149 +0,0 @@
-;   Copyright (c) Chris Houser, Jan 2009. All rights reserved.
-;   The use and distribution terms for this software are covered by the
-;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-;   which can be found in the file epl-v10.html at the root of this distribution.
-;   By using this software in any fashion, you are agreeing to be bound by
-;   the terms of this license.
-;   You must not remove this notice, or any other, from this software.
-
-; :dir and :env options added by Stuart Halloway
-
-; Conveniently launch a sub-process providing to its stdin and
-; collecting its stdout
-
-;; DEPRECATED in 1.2: Promoted to clojure.java.shell
-
-(ns 
-  ^{:author "Chris Houser",
-    :deprecated "1.2"
-    :doc "Conveniently launch a sub-process providing to its stdin and
-collecting its stdout"}
-  clojure.contrib.shell-out
-  (:import (java.io InputStreamReader OutputStreamWriter)))
-
-(def *sh-dir* nil)
-(def *sh-env* nil)
-
-(defmacro with-sh-dir [dir & forms]
-  "Sets the directory for use with sh, see sh for details."
-  `(binding [*sh-dir* ~dir]
-     ~@forms))
-
-(defmacro with-sh-env [env & forms]
-  "Sets the environment for use with sh, see sh for details."
-  `(binding [*sh-env* ~env]
-     ~@forms))
-     
-(defn- stream-seq
-  "Takes an InputStream and returns a lazy seq of integers from the stream."
-  [stream]
-  (take-while #(>= % 0) (repeatedly #(.read stream))))
-
-(defn- aconcat
-  "Concatenates arrays of given type."
-  [type & xs]
-  (let [target (make-array type (apply + (map count xs)))]
-    (loop [i 0 idx 0]
-      (when-let [a (nth xs i nil)]
-        (System/arraycopy a 0 target idx (count a))
-        (recur (inc i) (+ idx (count a)))))
-    target))
-
-(defn- parse-args
-  "Takes a seq of 'sh' arguments and returns a map of option keywords
-  to option values."
-  [args]
-  (loop [[arg :as args] args opts {:cmd [] :out "UTF-8" :dir *sh-dir* :env *sh-env*}]
-    (if-not args
-      opts
-      (if (keyword? arg)
-        (recur (nnext args) (assoc opts arg (second args)))
-        (recur (next args) (update-in opts [:cmd] conj arg))))))
-
-(defn- as-env-key [arg]
-  "Helper so that callers can use symbols, keywords, or strings
-   when building an environment map."
-  (cond
-   (symbol? arg) (name arg)
-   (keyword? arg) (name arg)
-   (string? arg) arg))
-
-(defn- as-file [arg]
-  "Helper so that callers can pass a String for the :dir to sh."   
-  (cond
-   (string? arg) (java.io.File. arg)
-   (nil? arg) nil
-   (instance? java.io.File arg) arg))
-   
-(defn- as-env-string [arg]
-  "Helper so that callers can pass a Clojure map for the :env to sh." 
-  (cond
-   (nil? arg) nil
-   (map? arg) (into-array String (map (fn [[k v]] (str (as-env-key k) "=" v)) arg))
-   true arg))
-
-
-(defn sh
-  "Passes the given strings to Runtime.exec() to launch a sub-process.
-
-  Options are
-
-  :in    may be given followed by a String specifying text to be fed to the 
-         sub-process's stdin.  
-  :out   option may be given followed by :bytes or a String. If a String 
-         is given, it will be used as a character encoding name (for 
-         example \"UTF-8\" or \"ISO-8859-1\") to convert the 
-         sub-process's stdout to a String which is returned.
-         If :bytes is given, the sub-process's stdout will be stored in 
-         a byte array and returned.  Defaults to UTF-8.
-  :return-map
-         when followed by boolean true, sh returns a map of
-           :exit => sub-process's exit code
-           :out  => sub-process's stdout (as byte[] or String)
-           :err  => sub-process's stderr (as byte[] or String)
-         when not given or followed by false, sh returns a single
-         array or String of the sub-process's stdout followed by its
-         stderr
-  :env   override the process env with a map (or the underlying Java
-         String[] if you are a masochist).
-  :dir   override the process dir with a String or java.io.File.
-
-  You can bind :env or :dir for multiple operations using with-sh-env
-  and with-sh-dir."
-  [& args]
-  (let [opts (parse-args args)
-        proc (.exec (Runtime/getRuntime) 
-		    (into-array (:cmd opts)) 
-		    (as-env-string (:env opts))
-		    (as-file (:dir opts)))]
-    (if (:in opts)
-      (with-open [osw (OutputStreamWriter. (.getOutputStream proc))]
-        (.write osw (:in opts)))
-      (.close (.getOutputStream proc)))
-    (with-open [stdout (.getInputStream proc)
-                stderr (.getErrorStream proc)]
-      (let [[[out err] combine-fn]
-                (if (= (:out opts) :bytes)
-                  [(for [strm [stdout stderr]]
-                    (into-array Byte/TYPE (map byte (stream-seq strm))))
-                  #(aconcat Byte/TYPE %1 %2)]
-                  [(for [strm [stdout stderr]]
-                    (apply str (map char (stream-seq 
-                                            (InputStreamReader. strm (:out opts))))))
-                  str])
-              exit-code (.waitFor proc)]
-        (if (:return-map opts)
-          {:exit exit-code :out out :err err}
-          (combine-fn out err))))))
-
-(comment
-
-(println (sh "ls" "-l"))
-(println (sh "ls" "-l" "/no-such-thing"))
-(println (sh "sed" "s/[aeiou]/oo/g" :in "hello there\n"))
-(println (sh "cat" :in "x\u25bax\n"))
-(println (sh "echo" "x\u25bax"))
-(println (sh "echo" "x\u25bax" :out "ISO-8859-1")) ; reads 4 single-byte chars
-(println (sh "cat" "myimage.png" :out :bytes)) ; reads binary file into bytes[]
-
-)
diff --git a/modules/shell/pom.xml b/modules/shell/pom.xml
deleted file mode 100644
index a74b677..0000000
--- a/modules/shell/pom.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http//www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-                             http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.clojure.contrib</groupId>
-    <artifactId>parent</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
-    <relativePath>../parent</relativePath>
-  </parent>
-  <artifactId>shell</artifactId>
-  <dependencies>
-  </dependencies>
-</project>
\ No newline at end of file
diff --git a/modules/shell/src/main/clojure/clojure/contrib/shell.clj b/modules/shell/src/main/clojure/clojure/contrib/shell.clj
deleted file mode 100644
index 6346766..0000000
--- a/modules/shell/src/main/clojure/clojure/contrib/shell.clj
+++ /dev/null
@@ -1,149 +0,0 @@
-;   Copyright (c) Chris Houser, Jan 2009. All rights reserved.
-;   The use and distribution terms for this software are covered by the
-;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
-;   which can be found in the file epl-v10.html at the root of this distribution.
-;   By using this software in any fashion, you are agreeing to be bound by
-;   the terms of this license.
-;   You must not remove this notice, or any other, from this software.
-
-; :dir and :env options added by Stuart Halloway
-
-; Conveniently launch a sub-process providing to its stdin and
-; collecting its stdout
-
-;; DEPRECATED in 1.2: Promoted to clojure.java.shell
-
-(ns 
-  ^{:author "Chris Houser",
-    :deprecated "1.2"
-    :doc "Conveniently launch a sub-process providing to its stdin and
-collecting its stdout"}
-  clojure.contrib.shell
-  (:import (java.io InputStreamReader OutputStreamWriter)))
-
-(def *sh-dir* nil)
-(def *sh-env* nil)
-
-(defmacro with-sh-dir [dir & forms]
-  "Sets the directory for use with sh, see sh for details."
-  `(binding [*sh-dir* ~dir]
-     ~@forms))
-
-(defmacro with-sh-env [env & forms]
-  "Sets the environment for use with sh, see sh for details."
-  `(binding [*sh-env* ~env]
-     ~@forms))
-     
-(defn- stream-seq
-  "Takes an InputStream and returns a lazy seq of integers from the stream."
-  [stream]
-  (take-while #(>= % 0) (repeatedly #(.read stream))))
-
-(defn- aconcat
-  "Concatenates arrays of given type."
-  [type & xs]
-  (let [target (make-array type (apply + (map count xs)))]
-    (loop [i 0 idx 0]
-      (when-let [a (nth xs i nil)]
-        (System/arraycopy a 0 target idx (count a))
-        (recur (inc i) (+ idx (count a)))))
-    target))
-
-(defn- parse-args
-  "Takes a seq of 'sh' arguments and returns a map of option keywords
-  to option values."
-  [args]
-  (loop [[arg :as args] args opts {:cmd [] :out "UTF-8" :dir *sh-dir* :env *sh-env*}]
-    (if-not args
-      opts
-      (if (keyword? arg)
-        (recur (nnext args) (assoc opts arg (second args)))
-        (recur (next args) (update-in opts [:cmd] conj arg))))))
-
-(defn- as-env-key [arg]
-  "Helper so that callers can use symbols, keywords, or strings
-   when building an environment map."
-  (cond
-   (symbol? arg) (name arg)
-   (keyword? arg) (name arg)
-   (string? arg) arg))
-
-(defn- as-file [arg]
-  "Helper so that callers can pass a String for the :dir to sh."   
-  (cond
-   (string? arg) (java.io.File. arg)
-   (nil? arg) nil
-   (instance? java.io.File arg) arg))
-   
-(defn- as-env-string [arg]
-  "Helper so that callers can pass a Clojure map for the :env to sh." 
-  (cond
-   (nil? arg) nil
-   (map? arg) (into-array String (map (fn [[k v]] (str (as-env-key k) "=" v)) arg))
-   true arg))
-
-
-(defn sh
-  "Passes the given strings to Runtime.exec() to launch a sub-process.
-
-  Options are
-
-  :in    may be given followed by a String specifying text to be fed to the 
-         sub-process's stdin.  
-  :out   option may be given followed by :bytes or a String. If a String 
-         is given, it will be used as a character encoding name (for 
-         example \"UTF-8\" or \"ISO-8859-1\") to convert the 
-         sub-process's stdout to a String which is returned.
-         If :bytes is given, the sub-process's stdout will be stored in 
-         a byte array and returned.  Defaults to UTF-8.
-  :return-map
-         when followed by boolean true, sh returns a map of
-           :exit => sub-process's exit code
-           :out  => sub-process's stdout (as byte[] or String)
-           :err  => sub-process's stderr (as byte[] or String)
-         when not given or followed by false, sh returns a single
-         array or String of the sub-process's stdout followed by its
-         stderr
-  :env   override the process env with a map (or the underlying Java
-         String[] if you are a masochist).
-  :dir   override the process dir with a String or java.io.File.
-
-  You can bind :env or :dir for multiple operations using with-sh-env
-  and with-sh-dir."
-  [& args]
-  (let [opts (parse-args args)
-        proc (.exec (Runtime/getRuntime) 
-		    (into-array (:cmd opts)) 
-		    (as-env-string (:env opts))
-		    (as-file (:dir opts)))]
-    (if (:in opts)
-      (with-open [osw (OutputStreamWriter. (.getOutputStream proc))]
-        (.write osw (:in opts)))
-      (.close (.getOutputStream proc)))
-    (with-open [stdout (.getInputStream proc)
-                stderr (.getErrorStream proc)]
-      (let [[[out err] combine-fn]
-                (if (= (:out opts) :bytes)
-                  [(for [strm [stdout stderr]]
-                    (into-array Byte/TYPE (map byte (stream-seq strm))))
-                  #(aconcat Byte/TYPE %1 %2)]
-                  [(for [strm [stdout stderr]]
-                    (apply str (map char (stream-seq 
-                                            (InputStreamReader. strm (:out opts))))))
-                  str])
-              exit-code (.waitFor proc)]
-        (if (:return-map opts)
-          {:exit exit-code :out out :err err}
-          (combine-fn out err))))))
-
-(comment
-
-(println (sh "ls" "-l"))
-(println (sh "ls" "-l" "/no-such-thing"))
-(println (sh "sed" "s/[aeiou]/oo/g" :in "hello there\n"))
-(println (sh "cat" :in "x\u25bax\n"))
-(println (sh "echo" "x\u25bax"))
-(println (sh "echo" "x\u25bax" :out "ISO-8859-1")) ; reads 4 single-byte chars
-(println (sh "cat" "myimage.png" :out :bytes)) ; reads binary file into bytes[]
-
-)
diff --git a/modules/shell/src/test/clojure/clojure/contrib/test_shell.clj b/modules/shell/src/test/clojure/clojure/contrib/test_shell.clj
deleted file mode 100644
index 120093e..0000000
--- a/modules/shell/src/test/clojure/clojure/contrib/test_shell.clj
+++ /dev/null
@@ -1,41 +0,0 @@
-(ns clojure.contrib.test-shell
-  (:use clojure.test
-	clojure.contrib.shell)
-  (:import (java.io File)))
-
-; workaroung to access private parse-args. Better way?
-(def parse-args ((ns-interns 'clojure.contrib.shell) 'parse-args))
-(def as-file ((ns-interns 'clojure.contrib.shell) 'as-file))
-(def as-env-string ((ns-interns 'clojure.contrib.shell) 'as-env-string))
-
-(deftest test-parse-args
-  (are [x y] (= x y)
-    {:cmd [nil] :out "UTF-8" :dir nil :env nil} (parse-args [])
-    {:cmd ["ls"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls"])
-    {:cmd ["ls" "-l"] :out "UTF-8" :dir nil :env nil} (parse-args ["ls" "-l"])
-    {:cmd ["ls"] :out "ISO-8859-1" :dir nil :env nil} (parse-args ["ls" :out "ISO-8859-1"])
-))
-  
-(deftest test-with-sh-dir
-  (are [x y] (= x y)
-    nil *sh-dir*
-    "foo" (with-sh-dir "foo" *sh-dir*)))
-
-(deftest test-with-sh-env
-  (are [x y] (= x y)
-    nil *sh-env*
-    {:KEY "VAL"} (with-sh-env {:KEY "VAL"} *sh-env*)))
-
-(deftest test-as-env-string
-  (are [x y] (= x y)
-    nil (as-env-string nil)
-    ["FOO=BAR"] (seq (as-env-string {"FOO" "BAR"}))
-    ["FOO_SYMBOL=BAR"] (seq (as-env-string {'FOO_SYMBOL "BAR"}))
-    ["FOO_KEYWORD=BAR"] (seq (as-env-string {:FOO_KEYWORD "BAR"}))))
-
-
-(deftest test-as-file
-  (are [x y] (= x y)
-    (File. "foo") (as-file "foo")
-    nil (as-file nil)
-    (File. "bar") (as-file (File. "bar"))))
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b8f3ff3..a704ce9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,8 +76,6 @@
     <module>modules/seq-utils</module>
     <module>modules/server-socket</module>
     <module>modules/set</module>
-    <module>modules/shell</module>
-    <module>modules/shell-out</module>
     <module>modules/singleton</module>
     <module>modules/sql</module>
     <module>modules/str-utils</module>
-- 
1.7.1

