ExpandShellAlias processes argv to see if it should be rewritten according to a user's aliases.
(expansion string, args []string, findShFunc func() (string, error))
| 106 | |
| 107 | // ExpandShellAlias processes argv to see if it should be rewritten according to a user's aliases. |
| 108 | func 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 | |
| 128 | func findSh() (string, error) { |
| 129 | shPath, err := findsh.Find() |
no outgoing calls