fix: parse command error (#231)

This commit is contained in:
Lykin 2024-04-17 18:34:49 +08:00
parent fc0deac074
commit 33caf873d6
1 changed files with 2 additions and 2 deletions

View File

@ -137,7 +137,7 @@ func SplitCmd(cmd string) []string {
var preChar int32 var preChar int32
inQuotes := false inQuotes := false
for _, char := range cmd { for _, char := range []rune(cmd) {
if char == '"' && preChar != '\\' { if char == '"' && preChar != '\\' {
inQuotes = !inQuotes inQuotes = !inQuotes
} else if char == ' ' && !inQuotes { } else if char == ' ' && !inQuotes {
@ -148,7 +148,7 @@ func SplitCmd(cmd string) []string {
curStr.Reset() curStr.Reset()
} }
} else { } else {
curStr.WriteByte(byte(char)) curStr.WriteRune(char)
} }
preChar = char preChar = char
} }