DetectShell returns a Shell instance from the given target. target is usually $0 and can also be prefixed by `-`
(target string)
| 50 | // |
| 51 | // target is usually $0 and can also be prefixed by `-` |
| 52 | func DetectShell(target string) Shell { |
| 53 | target = filepath.Base(target) |
| 54 | // $0 starts with "-" |
| 55 | if target[0:1] == "-" { |
| 56 | target = target[1:] |
| 57 | } |
| 58 | |
| 59 | detectedShell, isValid := supportedShellList[target] |
| 60 | if isValid { |
| 61 | return detectedShell |
| 62 | } |
| 63 | return nil |
| 64 | } |
no outgoing calls