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