add testcases for shlexsplit

This commit is contained in:
koba1t
2025-07-12 03:44:51 +09:00
parent 0fe722e99a
commit 042a2cf177
3 changed files with 198 additions and 4 deletions

View File

@@ -0,0 +1,19 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package execplugin
import (
"fmt"
shlex "github.com/carapace-sh/carapace-shlex"
)
func ShlexSplit(s string) ([]string, error) {
// return shlexSplit(s)
tokens, err := shlex.Split(s)
if err != nil {
return nil, fmt.Errorf("shlex split error: %w", err)
}
return tokens.Strings(), nil
}