Liking cljdoc? Tell your friends :D
Clojure only.

eyre.shell


gather-shellclj

(gather-shell {:keys [exec]})

Detects the shell running on the host reachable via exec and returns a map describing it.

Arguments

Takes a map with:

  • :exec - an executor function that runs a script string on the target host and returns {:exit int :out string :err string}.

Returns

A map with:

  • :type - keyword identifying the detected shell family: :bash, :zsh, :sh, :dash, :ksh, :busybox, :fish, :nu, :powershell or :cmd-exe. This is the type of the currently executing shell we are inside.
  • :version - the shell version string, e.g. "5.2.15(1)-release".
  • :shell - path of the currently running shell executable, i.e. the process actually executing the probe scripts. This is obtained from the running process (POSIX /proc/$$/exe / $0, the Windows process path, ...) and not from $SHELL, so it reflects the shell actually executing rather than the configured login shell, e.g. "/usr/bin/bash".
  • :login-shell - path of the users login shell $SHELL e.g. "/bin/bash".
  • :canonical-path - fully resolved path of the users login shell binary, e.g. "/usr/bin/bash". (For :cmd-exe there is a :path key instead, holding the value of %COMSPEC%.)

The returned map is the :shell input expected by the other fact gatherers (eyre.os/gather-os, eyre.hardware/gather-hardware, eyre.users/gather-users, eyre.filesystem/gather-filesystem, eyre.network/gather-network and eyre.bins/gather-paths), which use :type to select the appropriate embedded collection script.

Detection runs small embedded probe scripts through exec and inspects their output, so nothing needs to be installed on the target host. Asserts if any probe script exits non-zero.

Example

(shell/gather-shell {:exec local-exec})
;; => {:type :bash
;;     :version "5.2.15(1)-release"
;;     :shell "/usr/bin/bash"
;;     :login-shell "/bin/bash"
;;     :canonical-path "/usr/bin/bash"}
Detects the shell running on the host reachable via `exec` and
returns a map describing it.

## Arguments

Takes a map with:

- `:exec` - an executor function that runs a script string on the
  target host and returns `{:exit int :out string :err string}`.

## Returns

A map with:

- `:type` - keyword identifying the detected shell family: `:bash`,
  `:zsh`, `:sh`, `:dash`, `:ksh`, `:busybox`, `:fish`, `:nu`,
  `:powershell` or `:cmd-exe`. This is the type of the currently
  executing shell we are inside.
- `:version` - the shell version string, e.g. `"5.2.15(1)-release"`.
- `:shell` - path of the **currently running** shell executable, i.e.
  the process actually executing the probe scripts. This is obtained
  from the running process (POSIX `/proc/$$/exe` / `$0`, the Windows
  process path, ...) and not from `$SHELL`, so it reflects the shell
  actually executing rather than the configured login shell, e.g.
  `"/usr/bin/bash"`.
- `:login-shell` - path of the users **login shell** `$SHELL` e.g. `"/bin/bash"`.
- `:canonical-path` - fully resolved path of the users **login shell**
  binary, e.g. `"/usr/bin/bash"`. (For `:cmd-exe` there is a `:path` key
  instead, holding the value of `%COMSPEC%`.)

The returned map is the `:shell` input expected by the other fact
gatherers (`eyre.os/gather-os`, `eyre.hardware/gather-hardware`,
`eyre.users/gather-users`, `eyre.filesystem/gather-filesystem`,
`eyre.network/gather-network` and `eyre.bins/gather-paths`), which
use `:type` to select the appropriate embedded collection script.

Detection runs small embedded probe scripts through `exec` and
inspects their output, so nothing needs to be installed on the
target host. Asserts if any probe script exits non-zero.

## Example

```clojure
(shell/gather-shell {:exec local-exec})
;; => {:type :bash
;;     :version "5.2.15(1)-release"
;;     :shell "/usr/bin/bash"
;;     :login-shell "/bin/bash"
;;     :canonical-path "/usr/bin/bash"}
```
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