basilisp.shell¶
Support for launching a subprocess.
- dynamic Var *sh-dir*[source]¶
Bind to the value of the working directory to use for calls to
shif the:dirargument is not provided. Callers may use thewith-sh-dirmacro to bind this value for multiple calls tosh.Defaults to
nil, which will use the current working directory of this process.
- dynamic Var *sh-env*[source]¶
Bind to a map of environment variables to use for calls to
shif the:envargument is not provided. Callers may use thewith-sh-envmacro to bind this value for multiple calls tosh.Defaults to
nil, which will use the current process’s environment.
- fn (sh & args)[source]¶
Execute a shell command as a subprocess of the current process.
Commands are specified as a series of string arguments split on whitespace:
(sh "ls" "-la")
Following the command, 0 or more keyword/value pairs may be specified to control input and output options to the subprocess. The options are:
- keyword
:in: a string, byte string, byte array, file descriptor, or file object
- keyword
:in-enc: a string value matching one of Python’s supported encodings; if the value of
:inis a string, decode that string to bytes using the encoding named here; if none is specified,utf-8will be used; if the value of:inis not a string, this value will be ignored- keyword
:out-enc: a string value matching on of Python’s supported encodings or the special value
:bytes; if specified as a string, decode the standard out and standard error streams returned by the subprocess using this encoding; if specified as:bytes, return the byte string from the output without encoding; if none is specified,utf-8will be used- keyword
:env: a mapping of string values to string values which are used as the subprocess’s environment; if none is specified and
*sh-env*is not set, the environment of the current process will be used- keyword
:dir: a string indicating the working directory which is to be used for the subprocess; if none is specified and
*sh-dir*is not set, the working directory of the current process will be used
- keyword