mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-08 01:53:35 +02:00
zsh completion; Fix leading ~ in filenames being quoted on insertion into commandline
This commit is contained in:
@@ -24,3 +24,18 @@ func QuoteStringForFish(x string) string {
|
||||
x = strings.ReplaceAll(x, "'", "\\'")
|
||||
return "'" + x + "'"
|
||||
}
|
||||
|
||||
// Escapes common shell meta characters
|
||||
func EscapeSHMetaCharacters(x string) string {
|
||||
const metachars = "\\|&;<>()$'\" \n\t"
|
||||
ans := strings.Builder{}
|
||||
ans.Grow(len(x) + 32)
|
||||
for _, ch := range x {
|
||||
switch ch {
|
||||
case '\\', '|', '&', ';', '<', '>', '(', ')', '$', '\'', '"', ' ', '\n', '\t':
|
||||
ans.WriteRune('\\')
|
||||
}
|
||||
ans.WriteRune(ch)
|
||||
}
|
||||
return ans.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user