Show stdio output from ssh if getting options fails

This commit is contained in:
Kovid Goyal 2024-05-22 08:05:32 +05:30
parent f80b32df29
commit 61c5167554
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 1 deletions

View file

@ -41,7 +41,7 @@ var SSHOptions = sync.OnceValue(func() (ssh_options map[string]string) {
if err != nil {
return
}
if err := cmd.Start(); err != nil {
if err = cmd.Start(); err != nil {
return
}
raw, err := io.ReadAll(stderr)

View file

@ -5,6 +5,7 @@ package ssh
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
@ -18,6 +19,11 @@ var _ = fmt.Print
func TestGetSSHOptions(t *testing.T) {
m := SSHOptions()
if m["w"] != "local_tun[:remote_tun]" {
cmd := exec.Command(SSHExe())
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
t.Fatalf("Unexpected set of SSH options: %#v", m)
}
}