fix: parse command error (#231)
This commit is contained in:
parent
fc0deac074
commit
33caf873d6
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue