shell

package
v0.0.0-...-04d11d1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 6 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(s string) string

Escape escapes a string for shell.

func EscapeBytes

func EscapeBytes(s []byte) []byte

EscapeBytes escapes a byte array for shell.

func EscapeBytesNoQuotes

func EscapeBytesNoQuotes(s []byte) []byte

Escape escapes a byte array with backslashes.

func EscapeNoQuotes

func EscapeNoQuotes(s string) string

Escape escapes a string with backslashes.

func IsCommandSeparator

func IsCommandSeparator(text string) bool

func Split

func Split(text string) []string

Split splits a whole command line into tokens. Example: "cat fi\ le.txt|grep -V ^# >'out$$.txt' # Find non-comment lines." -> output: cat, fi\ le.txt, |, grep, -V, ^#, >, 'out$$.txt', # Find non-comment lines.

func Unescape

func Unescape(text string) string

func UnescapeBytes

func UnescapeBytes(b []byte) []byte

func UnescapeCLike

func UnescapeCLike(text string, buffer *bytes.Buffer, pos int) int

Types

type BashProxy

type BashProxy struct {
}

func (*BashProxy) Escape

func (s *BashProxy) Escape(text string) string

func (*BashProxy) GetCommandLine

func (s *BashProxy) GetCommandLine() (string, int)

GetCommandLine return the current command line and the cursor position from the READLINE_* environmental variables.

func (*BashProxy) PrintUpdateCommandLineEvalStr

func (s *BashProxy) PrintUpdateCommandLineEvalStr(commandLine string, cursorPos int)

PrintUpdateCommandLineEvalStr prints a string that can be evaled by bash to update the READLINE_* environmental variables to update the current command line.

func (*BashProxy) Split

func (s *BashProxy) Split(text string) []Token

func (*BashProxy) Unescape

func (s *BashProxy) Unescape(text string) string

type Proxy

type Proxy interface {
	GetCommandLine() (commandLine string, cursorPos int)
	PrintUpdateCommandLineEvalStr(commandLine string, cursorPos int)
	Split(text string) []Token
	Escape(text string) string
	Unescape(text string) string
}

func GetBashProxy

func GetBashProxy() Proxy

func GetProxy

func GetProxy() Proxy

func GetSupportedProxy

func GetSupportedProxy() Proxy

func GetZshProxy

func GetZshProxy() Proxy

func MustGetSupportedProxy

func MustGetSupportedProxy() Proxy

type Token

type Token struct {
	Word  string
	Index int
}

func SplitToTokens

func SplitToTokens(text string) []Token

type ZshProxy

type ZshProxy struct {
}

func (*ZshProxy) Escape

func (s *ZshProxy) Escape(text string) string

func (*ZshProxy) GetCommandLine

func (s *ZshProxy) GetCommandLine() (string, int)

func (*ZshProxy) PrintUpdateCommandLineEvalStr

func (s *ZshProxy) PrintUpdateCommandLineEvalStr(commandLine string, cursorPos int)

func (*ZshProxy) Split

func (s *ZshProxy) Split(text string) []Token

func (*ZshProxy) Unescape

func (s *ZshProxy) Unescape(text string) string

Jump to

Keyboard shortcuts

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