MCPcopy Create free account
hub / github.com/cli/cli / expandShellAlias

Function expandShellAlias

pkg/cmd/root/alias.go:107–125  ·  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

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

Callers 2

NewCmdShellAliasFunction · 0.85
TestExpandShellAliasFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExpandShellAliasFunction · 0.68