Source File
format_zsh.go
Belonging Package
github.com/carapace-sh/carapace-shlex/v2
package shlex// zshFormat implements Format for zsh lexing.// Extends bash with RC_QUOTES, zsh-specific operators (>>|, ;&, ;|, &|),// and WORDCHARS/FIGNORE for word breaks.type zshFormat struct{}func (zshFormat) () tokenClassifier {return bashFormat{}.Classifier() // zsh uses the same rune classes as bash}func (zshFormat) ( string) WordbreakType {switch {case ">>|":return WORDBREAK_REDIRECT_OUTPUT_APPEND_FORCEcase ";&":return WORDBREAK_LIST_FALLTHROUGHcase ";|":return WORDBREAK_LIST_FALLTHROUGH_RETRYcase "&|":return WORDBREAK_LIST_ASYNC_ERRCHECKdefault:return bashWordbreakType()}}func (zshFormat) () map[string]WordbreakType { return nil }func (zshFormat) () bool { return true } // RC_QUOTES: '' → 'func (zshFormat) () bool { return false }func (zshFormat) () bool { return true }func (zshFormat) () bool { return false }func (zshFormat) () map[rune]bool {return map[rune]bool{'\\': true,'`': true,'$': true,'"': true,'\n': true,}}func (zshFormat) ( string) string { return bashQuoteWord() }func (zshFormat) () bool { return false }func (zshFormat) () bool { return false }// IsLineContinuation implements lineContinuationEscaper. Zsh (like bash)// treats backslash followed by \n or \r as a line continuation.func (zshFormat) ( rune) bool {return == '\n' || == '\r'}// PostProcess reclassifies ( and ) as substitution delimiters and merges// $ + ( into a single opener token for POSIX command substitution.func (zshFormat) ( TokenSlice) TokenSlice {return posixSubstitutionPostProcess()}// Variable implements variableExpander. Zsh expands `$name` and `${name`;// `$` is literal inside single quotes and when escaped. Quote stripping at// insertion time is compsys's job (IPREFIX), not detection's.func (zshFormat) ( Token) (Variable, bool) {return posixVariableRef()}func (zshFormat) ( string) bool {return bareWordRe.MatchString()}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |