shenv

package
v0.0.0-...-b872246 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

Code in this directory was copy-pasted from the direnv codebase: https://github.com/direnv/direnv/blob/master/internal/cmd/

We could not directly import this code because in the direnv code it is inside an internal directory, and hence not exported.

Full credit to the direnv authors.

Documentation

Index

Constants

View Source
const (
	ACK           = 6
	TAB           = 9
	LF            = 10
	CR            = 13
	US            = 31
	SPACE         = 32
	AMPERSTAND    = 38
	SINGLE_QUOTE  = 39
	PLUS          = 43
	NINE          = 57
	QUESTION      = 63
	UPPERCASE_Z   = 90
	OPEN_BRACKET  = 91
	BACKSLASH     = 92
	UNDERSCORE    = 95
	CLOSE_BRACKET = 93
	BACKTICK      = 96
	LOWERCASE_Z   = 122
	TILDA         = 126
	DEL           = 127
)

nolint

Variables

This section is empty.

Functions

func BashEscape

func BashEscape(str string) string

https://github.com/solidsnack/shell-escape/blob/master/Text/ShellEscape/Bash.hs

A Bash escaped string. The strings are wrapped in @$\'...\'@ if any bytes within them must be escaped; otherwise, they are left as is. Newlines and other control characters are represented as ANSI escape sequences. High bytes are represented as hex codes. Thus Bash escaped strings will always fit on one line and never contain non-ASCII bytes.

Types

type Env

type Env map[string]string

type Shell

type Shell interface {
	// Hook is the string that gets evaluated into the host shell config and
	// setups direnv as a prompt hook.
	Hook() (string, error)

	// Export outputs the ShellExport as an evaluatable string on the host shell
	Export(e ShellExport) string

	// Dump outputs and evaluatable string that sets the env in the host shell
	Dump(env Env) string
}

Shell is the interface that represents the interaction with the host shell.

var Bash Shell = bash{}

Bash shell instance

var Fish Shell = fish{}

Fish adds support for the fish shell as a host

var Ksh Shell = ksh{}

Ksh adds support the korn shell

var Posix Shell = posix{}

Posix adds support for posix-compatible shells Specifically, in the context of devbox, this includes `dash`, `ash`, and `shell`

var UnknownSh Shell = unknown{}

UnknownSh adds support the unknown shell. This serves as a fallback alternative to outright failure.

var Zsh Shell = zsh{}

Zsh adds support for the venerable Z shell.

func DetectShell

func DetectShell(target string) Shell

DetectShell returns a Shell instance from the given shell name TODO: use a single common "enum" for both shenv and DevboxShell

type ShellExport

type ShellExport map[string]*string

ShellExport represents environment variables to add and remove on the host shell.

func (ShellExport) Add

func (e ShellExport) Add(key, value string)

Add represents the addition of a new environment variable

func (ShellExport) Remove

func (e ShellExport) Remove(key string)

Remove represents the removal of a given `key` environment variable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL