Documentation
¶
Overview ¶
Package shell provides generic helpers for launching subprocesses and interactive shells with a caller-supplied environment. It is intentionally free of any auth/secret-specific knowledge so multiple commands (e.g. `atmos auth exec`, `atmos secret exec`) can reuse it.
Index ¶
Constants ¶
const LevelEnvVar = "ATMOS_SHLVL"
LevelEnvVar is the environment variable tracking how deeply nested the current Atmos-managed shell is.
Variables ¶
This section is empty.
Functions ¶
func DecrementLevel ¶
func DecrementLevel()
DecrementLevel decrements the ATMOS_SHLVL environment variable, stopping at 0.
func Determine ¶
Determine resolves which shell binary to launch and which arguments to pass.
The shell is taken from (in order): the explicit override, the "shell" Viper key, then a platform default (cmd.exe on Windows; bash, falling back to sh, elsewhere). When no shell args are supplied, a login shell ("-l") is used by default on Unix.
func Level ¶
func Level() int
Level retrieves the current ATMOS_SHLVL value (0 when unset or invalid).
func RunCommand ¶
RunCommand executes args[0] with args[1:] using the supplied environment list, wiring stdin/stdout/stderr to the parent process.
The env list is passed to the child verbatim and must already be complete (e.g. os.Environ() + any additions) — do NOT prepend os.Environ() or convert to a map, as that would lose ordering and could collide on duplicate keys (such as Windows-style drive-scoped vars).
The child's exit code is propagated as errUtils.ExitCodeError so the root command can exit with the same status. A missing executable returns errUtils.ErrCommandNotFound with exit code 127 (the conventional shell "command not found" code), distinct from ErrUnknownSubcommand so the root handler does not mistake it for an unknown Atmos subcommand.
func StartInteractive ¶
StartInteractive launches an interactive shell process with the supplied environment, transferring stdin/stdout/stderr to it, and waits for the user to exit. The shell's exit code is propagated as errUtils.ExitCodeError.
Internally, os.StartProcess is used (rather than exec.Command) so the TTY is passed through directly for interactive sessions.
Types ¶
This section is empty.