Documentation
¶
Overview ¶
Package shell handles shell wrapper generation and installation for saws. Since a child process cannot modify its parent's environment, saws uses a shell function wrapper that evals the binary's --export output. This is the same pattern used by nvm, rbenv, direnv, and aws-vault.
Index ¶
- Constants
- func BinaryPath() (string, error)
- func Install(sh Shell, binaryPath string, rcPath string) error
- func IsInstalled(rcPath string) bool
- func IsWrapped() bool
- func RCFile(sh Shell) (string, error)
- func SupportedShells() []string
- func Uninstall(rcPath string) error
- func WrapperScript(sh Shell, binaryPath string) string
- type Shell
Constants ¶
const WrapperEnvVar = "SAWS_WRAPPER"
WrapperEnvVar is the environment variable set by the shell wrapper so the binary can detect whether it's running inside the wrapper.
Variables ¶
This section is empty.
Functions ¶
func BinaryPath ¶
BinaryPath returns the path to the saws binary. It first checks if the binary is in PATH, then falls back to the current executable.
func Install ¶
Install adds the saws wrapper function to the shell's rc file. If the block already exists, it replaces it. Otherwise, it appends it.
func IsInstalled ¶
IsInstalled checks if the saws wrapper is present in the given rc file.
func IsWrapped ¶
func IsWrapped() bool
IsWrapped returns true if the current process is running inside the shell wrapper.
func SupportedShells ¶
func SupportedShells() []string
SupportedShells returns the list of supported shell names.
func WrapperScript ¶
WrapperScript generates the shell wrapper function for the given shell. The wrapper:
- Sets SAWS_WRAPPER=1 so the binary knows it's wrapped
- Runs the binary with --export and any extra args
- Evals the output to set env vars in the parent shell
- Falls through to the real binary for non-credential flows (configure, version, etc.)
Types ¶
type Shell ¶
type Shell string
Shell represents a supported shell type.
func DetectShell ¶
DetectShell tries to determine the current shell from the SHELL environment variable.
func ParseShell ¶
ParseShell parses a shell name string into a Shell type.