Compare commits
2 Commits
b506e8a6a4
...
2388f309d8
Author | SHA1 | Date |
---|---|---|
Lykin | 2388f309d8 | |
Lykin | a9c7cb1cd2 |
|
@ -135,29 +135,38 @@ func SplitCmd(cmd string) []string {
|
|||
var result []string
|
||||
var curStr strings.Builder
|
||||
var preChar int32
|
||||
inQuotes := false
|
||||
var quotesChar int32
|
||||
|
||||
for _, char := range []rune(cmd) {
|
||||
if char == '"' && preChar != '\\' {
|
||||
inQuotes = !inQuotes
|
||||
} else if char == ' ' && !inQuotes {
|
||||
if curStr.Len() > 0 {
|
||||
if part, e := strconv.Unquote(`"` + curStr.String() + `"`); e == nil {
|
||||
result = append(result, part)
|
||||
cmdRune := []rune(cmd)
|
||||
for _, char := range cmdRune {
|
||||
if (char == '"' || char == '\'') && preChar != '\\' && (quotesChar == 0 || quotesChar == char) {
|
||||
if quotesChar != 0 {
|
||||
quotesChar = 0
|
||||
} else {
|
||||
quotesChar = char
|
||||
}
|
||||
} else if char == ' ' && quotesChar == 0 {
|
||||
result = append(result, curStr.String())
|
||||
curStr.Reset()
|
||||
}
|
||||
} else {
|
||||
curStr.WriteRune(char)
|
||||
}
|
||||
preChar = char
|
||||
}
|
||||
result = append(result, curStr.String())
|
||||
|
||||
if curStr.Len() > 0 {
|
||||
if part, e := strconv.Unquote(`"` + curStr.String() + `"`); e == nil {
|
||||
result = append(result, part)
|
||||
result = sliceutil.FilterMap(result, func(i int) (string, bool) {
|
||||
var part = strings.TrimSpace(result[i])
|
||||
if len(part) <= 0 {
|
||||
return "", false
|
||||
}
|
||||
if strings.Contains(part, "\\") {
|
||||
if unquotePart, e := strconv.Unquote(`"` + part + `"`); e == nil {
|
||||
return unquotePart, true
|
||||
}
|
||||
}
|
||||
return part, true
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -39,18 +39,6 @@ const props = defineProps({
|
|||
stroke="currentColor"
|
||||
stroke-linejoin="round" />
|
||||
<path :stroke-width="props.strokeWidth" d="M43 22H5" stroke="currentColor" stroke-linejoin="round" />
|
||||
<path
|
||||
:stroke-width="props.strokeWidth"
|
||||
d="M5 16V28"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
<path
|
||||
:stroke-width="props.strokeWidth"
|
||||
d="M43 16V28"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -37,18 +37,6 @@ const props = defineProps({
|
|||
d="M26 38H38"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
<path
|
||||
:stroke-width="props.strokeWidth"
|
||||
d="M44 37V27"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
<path
|
||||
:stroke-width="props.strokeWidth"
|
||||
d="M4 37V27"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
|
|
Loading…
Reference in New Issue