非常教程

Clojure 1.8参考手册

Clojure 1.8

clojure.java.shell

完整名称空间名称:clojure.java.shell

概述

Conveniently launch a sub-process providing its stdin and
collecting its stdout

公共变量和函数

施函数

Usage: (sh & args)
Passes the given strings to Runtime.exec() to launch a sub-process.

Options are

:in      may be given followed by any legal input source for
         clojure.java.io/copy, e.g. InputStream, Reader, File, byte[],
         or String, to be fed to the sub-process's stdin.
:in-enc  option may be given followed by a String, used as a character
         encoding name (for example "UTF-8" or "ISO-8859-1") to
         convert the input string specified by the :in option to the
         sub-process's stdin.  Defaults to UTF-8.
         If the :in option provides a byte array, then the bytes are passed
         unencoded, and this option is ignored.
:out-enc 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.
: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.

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 (String via platform default encoding)

在Clojure版本1.2中添加

来源

with-sh-dirmacro

Usage: (with-sh-dir dir & forms)
Sets the directory for use with sh, see sh for details.

在Clojure版本1.2中添加

来源

with-sh-envmacro

Usage: (with-sh-env env & forms)
Sets the environment for use with sh, see sh for details.

在Clojure版本1.2中添加

来源

Clojure 1.8

Clojure 是一种运行在 Java 平台上的 Lisp 方言,Lisp 是一种以表达性和功能强大著称的编程语言,但人们通常认为它不太适合应用于一般情况,而 Clojure 的出现彻底改变了这一现状。如今,在任何具备 Java 虚拟机的地方,您都可以利用 Lisp 的强大功能。

版本 1.8
发布版本 1.8

Clojure 1.8目录

1.Clojure 1.8