(logCtx context.Context, termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType, connName string)
| 581 | } |
| 582 | |
| 583 | func StartLocalShellProc(logCtx context.Context, termSize waveobj.TermSize, cmdStr string, cmdOpts CommandOptsType, connName string) (*ShellProc, error) { |
| 584 | if cmdOpts.SwapToken == nil { |
| 585 | return nil, fmt.Errorf("SwapToken is required in CommandOptsType") |
| 586 | } |
| 587 | shellutil.InitCustomShellStartupFiles() |
| 588 | var ecmd *exec.Cmd |
| 589 | var shellOpts []string |
| 590 | shellPath := cmdOpts.ShellPath |
| 591 | if shellPath == "" { |
| 592 | shellPath = shellutil.DetectLocalShellPath() |
| 593 | } |
| 594 | shellType := shellutil.GetShellTypeFromShellPath(shellPath) |
| 595 | shellOpts = append(shellOpts, cmdOpts.ShellOpts...) |
| 596 | var isShell bool |
| 597 | if cmdStr == "" { |
| 598 | isShell = true |
| 599 | if shellType == shellutil.ShellType_bash { |
| 600 | // add --rcfile |
| 601 | // cant set -l or -i with --rcfile |
| 602 | shellOpts = append(shellOpts, "--rcfile", shellutil.GetLocalBashRcFileOverride()) |
| 603 | } else if shellType == shellutil.ShellType_fish { |
| 604 | if cmdOpts.Login { |
| 605 | shellOpts = append(shellOpts, "-l") |
| 606 | } |
| 607 | waveFishPath := shellutil.GetLocalWaveFishFilePath() |
| 608 | carg := fmt.Sprintf("source %s", shellutil.HardQuoteFish(waveFishPath)) |
| 609 | shellOpts = append(shellOpts, "-C", carg) |
| 610 | } else if shellType == shellutil.ShellType_pwsh { |
| 611 | shellOpts = append(shellOpts, "-ExecutionPolicy", "Bypass", "-NoExit", "-File", shellutil.GetLocalWavePowershellEnv()) |
| 612 | } else { |
| 613 | if cmdOpts.Login { |
| 614 | shellOpts = append(shellOpts, "-l") |
| 615 | } |
| 616 | if cmdOpts.Interactive { |
| 617 | shellOpts = append(shellOpts, "-i") |
| 618 | } |
| 619 | } |
| 620 | blocklogger.Debugf(logCtx, "[conndebug] shell:%s shellOpts:%v\n", shellPath, shellOpts) |
| 621 | ecmd = exec.Command(shellPath, shellOpts...) |
| 622 | ecmd.Env = os.Environ() |
| 623 | if shellType == shellutil.ShellType_zsh { |
| 624 | shellutil.UpdateCmdEnv(ecmd, map[string]string{"ZDOTDIR": shellutil.GetLocalZshZDotDir()}) |
| 625 | } |
| 626 | } else { |
| 627 | isShell = false |
| 628 | shellOpts = append(shellOpts, "-c", cmdStr) |
| 629 | ecmd = exec.Command(shellPath, shellOpts...) |
| 630 | ecmd.Env = os.Environ() |
| 631 | } |
| 632 | |
| 633 | packedToken, err := cmdOpts.SwapToken.PackForClient() |
| 634 | if err != nil { |
| 635 | blocklogger.Infof(logCtx, "error packing swap token: %v", err) |
| 636 | } else { |
| 637 | blocklogger.Debugf(logCtx, "packed swaptoken %s\n", packedToken) |
| 638 | shellutil.UpdateCmdEnv(ecmd, map[string]string{wavebase.WaveSwapTokenVarName: packedToken}) |
| 639 | } |
| 640 | jwtToken := cmdOpts.SwapToken.Env[wavebase.WaveJwtTokenVarName] |
no test coverage detected