Liking cljdoc? Tell your friends :D

hive-system.shell.core

IShell implementation via ProcessBuilder. All operations return hive-dsl Results.

Stream draining and process-tree teardown are shared with the IProcess implementation — see hive-system.process.streams / .tree. Both faced the same hazard (a descendant holding an inherited pipe), and one copy of the answer is the point.

IShell implementation via ProcessBuilder.
All operations return hive-dsl Results.

Stream draining and process-tree teardown are shared with the IProcess
implementation — see hive-system.process.streams / .tree. Both faced the
same hazard (a descendant holding an inherited pipe), and one copy of the
answer is the point.
raw docstring

envclj

(env)

Get environment variables as map.

Get environment variables as map.
sourceraw docstring

exec!clj

(exec! cmd)
(exec! cmd opts)

Execute a shell command. Returns Result. cmd can be a string (passed to sh -c) or a vector of args.

Opts: :dir — working directory :env — extra env vars map :timeout-ms — kill after N ms (default 30s)

Execute a shell command. Returns Result.
cmd can be a string (passed to sh -c) or a vector of args.

Opts:
  :dir        — working directory
  :env        — extra env vars map
  :timeout-ms — kill after N ms (default 30s)
sourceraw docstring

exec-ok!clj

(exec-ok! cmd)
(exec-ok! cmd opts)

Like exec! but returns (err ...) if exit code is non-zero.

Like exec! but returns (err ...) if exit code is non-zero.
sourceraw docstring

lines!clj

(lines! cmd)
(lines! cmd opts)

Run a command, reading at most a bounded number of output lines. Result.

exec! captures everything the command printed, so its memory cost is set by the child. Use this where the caller has a budget:

(lines! ["rg" "--files" root] {:max-lines 1000}) => (ok {:lines […] :truncated? true :reason :max-lines :exit nil …})

Opts, on top of exec!'s: :max-lines — lines to return (default 1000) :max-bytes — total bytes to read (default 8 MiB). A line budget does not bound memory; one pathological line exhausts the heap with the line count still at 1.

:truncated? is the load-bearing key. A caller handed exactly :max-lines lines cannot otherwise tell a command that printed that many from one that printed more, and a silently truncated list reads as a complete answer. :reason names which bound stopped it: :eof, :max-lines or :max-bytes.

When truncated the process TREE is destroyed — a cap is a decision to stop the producer, not merely to stop reading it — and :exit is nil, because the only status such a process could report describes the kill.

Run a command, reading at most a bounded number of output lines. Result.

`exec!` captures everything the command printed, so its memory cost is set
by the child. Use this where the caller has a budget:

  (lines! ["rg" "--files" root] {:max-lines 1000})
  => (ok {:lines […] :truncated? true :reason :max-lines :exit nil …})

Opts, on top of `exec!`'s:
  :max-lines  — lines to return (default 1000)
  :max-bytes  — total bytes to read (default 8 MiB). A line budget does not
                bound memory; one pathological line exhausts the heap with
                the line count still at 1.

`:truncated?` is the load-bearing key. A caller handed exactly :max-lines
lines cannot otherwise tell a command that printed that many from one that
printed more, and a silently truncated list reads as a complete answer.
`:reason` names which bound stopped it: :eof, :max-lines or :max-bytes.

When truncated the process TREE is destroyed — a cap is a decision to stop
the producer, not merely to stop reading it — and `:exit` is nil, because
the only status such a process could report describes the kill.
sourceraw docstring

make-shellclj

(make-shell)
(make-shell opts)

Create a Shell instance with optional default opts. Opts: :dir, :env, :timeout-ms.

Create a Shell instance with optional default opts.
Opts: :dir, :env, :timeout-ms.
sourceraw docstring

require-toolclj

(require-tool tool-key)

Check tool availability with install hints. See shell.tools/require-tool.

Check tool availability with install hints. See shell.tools/require-tool.
sourceraw docstring

whichclj

(which program)

Resolve program to path. Returns Result.

Resolve program to path. Returns Result.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close