/process
Subprocess execution (run, spawn), environment variables (env, env-vars), working directory, and exit statuses.
Functions & symbols#
args#
Returns the array of command-line arguments passed to the running script.
Any(let [file target] (process/args))env#
Reads environment variables. With 0 args returns a Map of all vars; with 1 arg returns the value or (); with 2 args returns fallback when unset.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | required | Environment variable name |
default | Any | required | Fallback value if variable is unset |
Any(let vars (process/env))(let port (process/env "PORT" "8080"))env-vars#
Returns all environment variables inherited by the current process as a `Map`.
Any(let env (process/env-vars))err-port#
Host standard error stream handle implementing `Write`, `Write-Text`, and `Flush`.
Any(use {err-port} /process)
(write-line err-port "error!")exec#
Executes a shell command and captures its standard output as a String.
| Parameter | Type | Optional | Description |
|---|---|---|---|
cmd | String | required | Shell command string to execute |
Any(let out (process/exec "git rev-parse HEAD"))exit#
Terminates the process with exit `code` (deprecated alias; prefer `process/exit-process`).
| Parameter | Type | Optional | Description |
|---|---|---|---|
code | Int | required | Process exit status code (0 for success) |
Anyexit!#
Immediately terminates the current process with the given integer exit code (defaults to 0).
| Parameter | Type | Optional | Description |
|---|---|---|---|
code | Int | required | Exit status code (0 for success, 1+ for failure) |
Any(process/exit! 1)expect-env-var#
Returns the value of the environment variable `name`, or panics if undefined.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | Any | required | — |
Anyget-args#
Returns CLI command-line arguments passed to the current program.
Any(let args (process/get-args))get-env#
Looks up an environment variable by name, returning `()` if unset.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | KeySymbol | required | Environment variable name |
Any(process/get-env "HOME")has-env?#
Returns true if the environment variable is set in the current process.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | required | Environment variable name |
Any(if (process/has-env? "DEBUG") (writeln "debugging enabled"))in-port#
Host standard input stream handle implementing `Read` and `Read-Text`.
Any(use {in-port} /process)
(let line (read-line in-port))out-port#
Host standard output stream handle implementing `Write`, `Write-Text`, and `Flush`.
Any(use {out-port} /process)
(write-line out-port "hello")pid#
Returns the current process identifier (PID).
Any(let current-pid (process/pid))run#
Executes a subprocess directly without invoking `sh -c`, preventing shell command injection and returning `{:code Int :out String :err String :ok? Bool}`.
| Parameter | Type | Optional | Description |
|---|---|---|---|
cmd | (Array String) | String | required | Executable and argument array executed directly without a shell |
options | Map | required | Optional execution options (`:cwd`, `:env`, `:clear-env`, `:in`) |
Any(let res (process/run ["git" "status" "--porcelain"]))(let res (process/run ["env"] {:clear-env true :env {:MODE "safe"}}))set-env#
Sets an environment variable for the current process.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | required | Environment variable name |
value | String | required | Environment variable value |
Any(process/set-env "API_KEY" "secret")set-env-var#
Sets an environment variable for the current process and spawned children.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | KeySymbol | required | Variable name |
value | String | required | Value to set |
Any(process/set-env-var "LOG_LEVEL" "debug")shell#
Executes a shell command streaming standard I/O to the console, returning the exit status code.
| Parameter | Type | Optional | Description |
|---|---|---|---|
cmd | String | required | Shell command string to execute |
Any(let code (process/shell "npm test"))unset-env#
Unsets an environment variable from the current process.
| Parameter | Type | Optional | Description |
|---|---|---|---|
name | String | required | Environment variable name |
Any(process/unset-env "API_KEY")