Documentation ¶
Index ¶
- Constants
- Variables
- func BashDeclareStmt(d *DeclareDeclType) string
- func DecodeZshMapForDiff(barr []byte) (map[string][]byte, error)
- func DetectLocalShellType() string
- func EncodeZshMap(m ZshMap) []byte
- func EncodeZshMapForApply(m map[string][]byte) string
- func GetBashShellState(ctx context.Context, outCh chan ShellStateOutput, stdinDataCh chan []byte)
- func GetBashShellStateCmd(fdNum int) (string, []byte)
- func GetBashShellStateRedirectCommandStr(outputFdNum int) (string, []byte)
- func GetLocalBashMajorVersion() string
- func GetLocalBashPath() string
- func GetLocalZshMajorVersion() string
- func GetLocalZshPath() string
- func GetMacUserShell() string
- func GetParserConfig(envMap map[string]string) *expand.Config
- func GetZshShellStateCmd(fdNum int) (string, []byte)
- func HasShell(shellType string) bool
- func MakeBashExitTrap(fdNum int) (string, []byte)
- func MakeBashShExecCommand(cmdStr string, rcFileName string, usePty bool) *exec.Cmd
- func MakeZshExitTrap(fdNum int) (string, []byte)
- func ParseZshFunctions(fpathArr []string, fnBytes []byte, partSeparator []byte) map[ZshParamKey]string
- func RunSimpleCmdInPty(ecmd *exec.Cmd, endBytes []byte) ([]byte, error)
- func StreamCommandWithExtraFd(ctx context.Context, ecmd *exec.Cmd, outputCh chan []byte, extraFdNum int, ...) ([]byte, error)
- type DeclareDeclType
- type RunCommandOpts
- type ShellApi
- type ShellStateOutput
- type ZshMap
- type ZshParamKey
Constants ¶
View Source
const ( BashSection_Ignored = iota BashSection_Version BashSection_Cwd BashSection_Vars BashSection_Aliases BashSection_Funcs BashSection_PVars BashSection_EndBytes BashSection_Count // must be last )
View Source
const ( ZshSection_Version = iota ZshSection_Cwd ZshSection_Env ZshSection_Mods ZshSection_Vars ZshSection_Aliases ZshSection_Fpath ZshSection_Funcs ZshSection_PVars ZshSection_Prompt ZshSection_EndBytes ZshSection_NumFieldsExpected // must be last )
View Source
const BaseBashOpts = `set +m; set +H; shopt -s extglob`
View Source
const BaseZshOpts = ``
View Source
const BashShellVersionCmdStr = `echo bash v${BASH_VERSINFO[0]}.${BASH_VERSINFO[1]}.${BASH_VERSINFO[2]}`
View Source
const DebugState = false
View Source
const DefaultMacOSShell = "/bin/bash"
View Source
const FirstExtraFilesFdNum = 3
View Source
const GetGitBranchCmdStr = `printf "GITBRANCH %s\x00" "$(git rev-parse --abbrev-ref HEAD 2>/dev/null)"`
View Source
const GetK8sContextCmdStr = `printf "K8SCONTEXT %s\x00" "$(kubectl config current-context 2>/dev/null)"`
View Source
const GetK8sNamespaceCmdStr = `printf "K8SNAMESPACE %s\x00" "$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)"`
View Source
const GetVersionTimeout = 5 * time.Second
View Source
const NumRandomEndBytes = 8
View Source
const RemoteBashPath = "bash"
View Source
const RunBashSudoCommandFmt = `sudo -n -C %d bash /dev/fd/%d`
TODO fix bash path in these constants
View Source
const RunBashSudoPasswordCommandFmt = `cat /dev/fd/%d | sudo -k -S -C %d bash -c "echo '[from-mshell]'; exec %d>&-; bash /dev/fd/%d < /dev/fd/%d"`
View Source
const RunCommandFmt = `%s`
View Source
const RunZshSudoCommandFmt = `sudo -n -C %d zsh /dev/fd/%d`
TODO these need updating
View Source
const RunZshSudoPasswordCommandFmt = `cat /dev/fd/%d | sudo -k -S -C %d zsh -c "echo '[from-mshell]'; exec %d>&-; zsh /dev/fd/%d < /dev/fd/%d"`
View Source
const (
ShellStateOutputStatus_Done = "done"
)
View Source
const StateOutputFdNum = 20
View Source
const ValidateTimeout = 2 * time.Second
View Source
const ZModsVarName = "WAVESTATE_ZMODS"
View Source
const ZshAutoloadFnBody = "builtin autoload -XU"
View Source
const ZshFnAutoLoad = "autoload"
sentinel value for functions that should be autoloaded
View Source
const ZshShellVersionCmdStr = `echo zsh v$ZSH_VERSION`
Variables ¶
View Source
var BashNoStoreVarNames = map[string]bool{ "BASH": true, "BASHOPTS": true, "BASHPID": true, "BASH_ALIASES": true, "BASH_ARGC": true, "BASH_ARGV": true, "BASH_ARGV0": true, "BASH_CMDS": true, "BASH_COMMAND": true, "BASH_EXECUTION_STRING": true, "LINENO": true, "BASH_LINENO": true, "BASH_REMATCH": true, "BASH_SOURCE": true, "BASH_SUBSHELL": true, "COPROC": true, "DIRSTACK": true, "EPOCHREALTIME": true, "EPOCHSECONDS": true, "FUNCNAME": true, "HISTCMD": true, "OLDPWD": true, "PIPESTATUS": true, "PPID": true, "PWD": true, "RANDOM": true, "SECONDS": true, "SHLVL": true, "HISTFILE": true, "HISTFILESIZE": true, "HISTCONTROL": true, "HISTIGNORE": true, "HISTSIZE": true, "HISTTIMEFORMAT": true, "SRANDOM": true, "COLUMNS": true, "LINES": true, }
https://wiki.bash-hackers.org/syntax/shellvars
View Source
var GetBashShellStateCmds = []string{ "exec 2> /dev/null;", BashShellVersionCmdStr + ";", `pwd;`, `declare -p $(compgen -A variable);`, `alias -p;`, `declare -f;`, GetGitBranchCmdStr + ";", }
the "exec 2>" line also adds an extra printf at the *beginning* to strip out spurious rc file output
View Source
var ZshForceLoadMods = map[string]bool{ "zsh/parameter": true, "zsh/langinfo": true, }
View Source
var ZshForceOptions = map[string]bool{ "globalrcs": false, "ksharrays": false, "kshtypeset": false, "kshautoload": false, "kshzerosubscript": false, "xtrace": false, "verbose": false, "debugbeforecmd": false, }
force these options on/off at beginning of rcfile
View Source
var ZshIgnoreFuncs = map[string]bool{ "zftp_chpwd": true, "zftp_progress": true, }
View Source
var ZshIgnoreOptions = map[string]bool{ "globalrcs": true, "ksharrays": true, "kshtypeset": true, "kshautoload": true, "kshzerosubscript": true, "interactive": true, "login": true, "zle": true, "shinstdin": true, "privileged": true, "restricted": true, "singlecommand": true, }
only options we restore (other than ZshForceOptions)
View Source
var ZshIgnoreVars = map[string]bool{ "_": true, "0": true, "terminfo": true, "RANDOM": true, "COLUMNS": true, "LINES": true, "argv": true, "SECONDS": true, "PWD": true, "HISTCHARS": true, "HISTFILE": true, "HISTSIZE": true, "SAVEHIST": true, "ZSH_EXECUTION_STRING": true, "EPOCHSECONDS": true, "EPOCHREALTIME": true, "SHLVL": true, "TTY": true, "ZDOTDIR": true, "PPID": true, "epochtime": true, "langinfo": true, "keymaps": true, "widgets": true, "options": true, "aliases": true, "dis_aliases": true, "saliases": true, "dis_saliases": true, "galiases": true, "dis_galiases": true, "builtins": true, "dis_builtins": true, "modules": true, "history": true, "historywords": true, "jobdirs": true, "jobstates": true, "jobtexts": true, "funcfiletrace": true, "funcsourcetrace": true, "funcstack": true, "functrace": true, "nameddirs": true, "userdirs": true, "parameters": true, "commands": true, "functions": true, "dis_functions": true, "functions_source": true, "dis_functions_source": true, "_comps": true, "_patcomps": true, "_postpatcomps": true, "errnos": true, "sysparams": true, "ZCURSES_COLORS": true, "ZCURSES_COLOR_PAIRS": true, "zcurses_attrs": true, "zcurses_colors": true, "zcurses_keycodes": true, "zcurses_windows": true, "_GITSTATUS_CLIENT_PID_POWERLEVEL9K": true, "GITSTATUS_DAEMON_PID_POWERLEVEL9K": true, "_GITSTATUS_FILE_PREFIX_POWERLEVEL9K": true, }
View Source
var ZshSpecialDecls = map[string]bool{ "precmd_functions": true, "preexec_functions": true, }
View Source
var ZshUniqueArrayVars = map[string]bool{ "path": true, "fpath": true, }
View Source
var ZshUnsetVars = []string{
"HISTFILE",
"ZSH_EXECUTION_STRING",
}
Functions ¶
func BashDeclareStmt ¶
func BashDeclareStmt(d *DeclareDeclType) string
func DetectLocalShellType ¶
func DetectLocalShellType() string
func EncodeZshMap ¶
func EncodeZshMapForApply ¶
func GetBashShellState ¶
func GetBashShellState(ctx context.Context, outCh chan ShellStateOutput, stdinDataCh chan []byte)
func GetBashShellStateCmd ¶
func GetLocalBashMajorVersion ¶
func GetLocalBashMajorVersion() string
func GetLocalBashPath ¶
func GetLocalBashPath() string
func GetLocalZshMajorVersion ¶
func GetLocalZshMajorVersion() string
func GetLocalZshPath ¶
func GetLocalZshPath() string
func GetMacUserShell ¶
func GetMacUserShell() string
func GetZshShellStateCmd ¶
returns (cmd-string, endbytes)
func MakeBashExitTrap ¶
func MakeBashShExecCommand ¶
func MakeZshExitTrap ¶
func ParseZshFunctions ¶
func ParseZshFunctions(fpathArr []string, fnBytes []byte, partSeparator []byte) map[ZshParamKey]string
Types ¶
type DeclareDeclType ¶
type DeclareDeclType = shellenv.DeclareDeclType
type RunCommandOpts ¶
type ShellApi ¶
type ShellApi interface { GetShellType() string MakeExitTrap(fdNum int) (string, []byte) ValidateCommandSyntax(cmdStr string) error GetLocalMajorVersion() string GetLocalShellPath() string GetRemoteShellPath() string MakeRunCommand(cmdStr string, opts RunCommandOpts) string MakeShExecCommand(cmdStr string, rcFileName string, usePty bool) *exec.Cmd GetShellState(ctx context.Context, outCh chan ShellStateOutput, stdinDataCh chan []byte) GetBaseShellOpts() string ParseShellStateOutput(output []byte) (*packet.ShellState, *packet.ShellStateStats, error) MakeRcFileStr(pk *packet.RunPacketType) string MakeShellStateDiff(oldState *packet.ShellState, oldStateHash string, newState *packet.ShellState) (*packet.ShellStateDiff, error) ApplyShellStateDiff(oldState *packet.ShellState, diff *packet.ShellStateDiff) (*packet.ShellState, error) }
func MakeShellApi ¶
type ShellStateOutput ¶
type ShellStateOutput struct { Output []byte ShellState *packet.ShellState Stats *packet.ShellStateStats Error string }
type ZshParamKey ¶
type ZshParamKey struct { // paramtype cannot contain spaces // "aliases", "dis_aliases", "saliases", "dis_saliases", "galiases", "dis_galiases" // "functions", "dis_functions", "functions_source", "dis_functions_source" ParamType string ParamName string }
func ZshParamKeyFromString ¶
func ZshParamKeyFromString(s string) (ZshParamKey, error)
func (ZshParamKey) String ¶
func (k ZshParamKey) String() string
Click to show internal directories.
Click to hide internal directories.