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

Function expandShellAlias

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

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

Callers 2

NewCmdShellAliasFunction · 0.85
TestExpandShellAliasFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExpandShellAliasFunction · 0.68