From 5ea05ebdfaad49bf3fcf0e076f97c15d17910bcd Mon Sep 17 00:00:00 2001 From: Eduardo Argollo Date: Mon, 17 Jun 2019 20:36:49 -0700 Subject: [PATCH] Solves proxy issue, closes #74 when proxy is set at .profile --- sshcode.go | 8 ++++---- sshcode_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sshcode.go b/sshcode.go index 97e7502..c519420 100644 --- a/sshcode.go +++ b/sshcode.go @@ -56,9 +56,9 @@ func sshCode(host, dir string, o options) error { dlScript := downloadScript(codeServerPath) // Downloads the latest code-server and allows it to be executed. - sshCmdStr := fmt.Sprintf("ssh %v %v '/usr/bin/env bash'", o.sshFlags, host) + sshCmdStr := fmt.Sprintf("ssh %v %v '/usr/bin/env bash -l'", o.sshFlags, host) - sshCmd := exec.Command("sh", "-c", sshCmdStr) + sshCmd := exec.Command("sh", "-l", "-c", sshCmdStr) sshCmd.Stdout = os.Stdout sshCmd.Stderr = os.Stderr sshCmd.Stdin = strings.NewReader(dlScript) @@ -99,7 +99,7 @@ func sshCode(host, dir string, o options) error { ) // Starts code-server and forwards the remote port. - sshCmd = exec.Command("sh", "-c", sshCmdStr) + sshCmd = exec.Command("sh", "-l", "-c", sshCmdStr) sshCmd.Stdin = os.Stdin sshCmd.Stdout = os.Stdout sshCmd.Stderr = os.Stderr @@ -396,7 +396,7 @@ func parseHost(host string) (parsedHost string, additionalFlags string, err erro func parseGCPSSHCmd(instance string) (ip, sshFlags string, err error) { dryRunCmd := fmt.Sprintf("gcloud compute ssh --dry-run %v", instance) - out, err := exec.Command("sh", "-c", dryRunCmd).CombinedOutput() + out, err := exec.Command("sh", "-l", "-c", dryRunCmd).CombinedOutput() if err != nil { return "", "", xerrors.Errorf("%s: %w", out, err) } diff --git a/sshcode_test.go b/sshcode_test.go index fc6eb7d..096bff6 100644 --- a/sshcode_test.go +++ b/sshcode_test.go @@ -48,7 +48,7 @@ func TestSSHCode(t *testing.T) { waitForSSHCode(t, remotePort, time.Second*30) // Typically we'd do an os.Stat call here but the os package doesn't expand '~' - out, err := exec.Command("sh", "-c", "stat "+codeServerPath).CombinedOutput() + out, err := exec.Command("sh", "-l", "-c", "stat "+codeServerPath).CombinedOutput() require.NoError(t, err, "%s", out) out, err = exec.Command("pkill", filepath.Base(codeServerPath)).CombinedOutput() @@ -200,7 +200,7 @@ func handleSession(ch ssh.Channel, in <-chan *ssh.Request, t *testing.T) { return } - cmd := exec.Command("sh", "-c", exReq.Command) + cmd := exec.Command("sh", "-l", "-c", exReq.Command) stdin, err := cmd.StdinPipe() require.NoError(t, err)