MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / DetectShellTypeAndVersionFromPath

Function DetectShellTypeAndVersionFromPath

pkg/util/shellutil/shellutil.go:494–511  ·  view source on GitHub ↗
(shellPath string)

Source from the content-addressed store, hash-verified

492}
493
494func DetectShellTypeAndVersionFromPath(shellPath string) (string, string, error) {
495 shellType := GetShellTypeFromShellPath(shellPath)
496 if shellType == ShellType_unknown {
497 return shellType, "", fmt.Errorf("unknown shell type: %s", shellPath)
498 }
499
500 shellBase := filepath.Base(shellPath)
501 if shellType == ShellType_pwsh && strings.Contains(shellBase, "powershell") && !strings.Contains(shellBase, "pwsh") {
502 return "powershell", "", nil
503 }
504
505 version, err := getShellVersion(shellPath, shellType)
506 if err != nil {
507 return shellType, "", err
508 }
509
510 return shellType, version, nil
511}
512
513func getShellVersion(shellPath string, shellType string) (string, error) {
514 ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)

Callers 1

Calls 2

getShellVersionFunction · 0.85

Tested by

no test coverage detected