MCPcopy
hub / github.com/cli/cli / expandShellAlias

Function expandShellAlias

pkg/cmd/root/alias.go:105–123  ·  view source on GitHub ↗

ExpandShellAlias processes argv to see if it should be rewritten according to a user's aliases.

(expansion string, args []string, findShFunc func() (string, error))

Source from the content-addressed store, hash-verified

103
104// ExpandShellAlias processes argv to see if it should be rewritten according to a user's aliases.
105func expandShellAlias(expansion string, args []string, findShFunc func() (string, error)) ([]string, error) {
106 if findShFunc == nil {
107 findShFunc = findSh
108 }
109
110 shPath, shErr := findShFunc()
111 if shErr != nil {
112 return nil, shErr
113 }
114
115 expanded := []string{shPath, "-c", expansion[1:]}
116
117 if len(args) > 0 {
118 expanded = append(expanded, "--")
119 expanded = append(expanded, args...)
120 }
121
122 return expanded, nil
123}
124
125func findSh() (string, error) {
126 shPath, err := findsh.Find()

Callers 2

NewCmdShellAliasFunction · 0.85
TestExpandShellAliasFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExpandShellAliasFunction · 0.68