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.
(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)
(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.
(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.(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.
(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.
(which program)Resolve program to path. Returns Result.
Resolve program to path. Returns Result.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |