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