From 09a072f9007a6670024603fea053203abd6004fd Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 24 Aug 2022 02:11:49 -0700 Subject: [PATCH] run localhost mshell with cwd at HOME, not in current directory --- pkg/shexec/shexec.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/shexec/shexec.go b/pkg/shexec/shexec.go index 32fc3448..dbfd35e9 100644 --- a/pkg/shexec/shexec.go +++ b/pkg/shexec/shexec.go @@ -391,7 +391,12 @@ func (opts SSHOpts) MakeMShellSingleCmd() (*exec.Cmd, error) { func (opts SSHOpts) MakeSSHExecCmd(remoteCommand string) *exec.Cmd { remoteCommand = strings.TrimSpace(remoteCommand) if opts.SSHHost == "" { + homeDir, _ := os.UserHomeDir() // ignore error + if homeDir == "" { + homeDir = "/" + } ecmd := exec.Command("bash", "-c", remoteCommand) + ecmd.Dir = homeDir return ecmd } else { var moreSSHOpts []string