From c1c12faa01d0f1d993bb0064a70fa02bfc28b3b7 Mon Sep 17 00:00:00 2001 From: A2uria Date: Thu, 3 Dec 2026 11:30:01 +0800 Subject: [PATCH] cmd/tailcat: hardcode /dev/null instead of os.DevNull On Windows, os.DevNull resolves to "NUL". When the openssh from msys2/git-for-windows is used, "NUL" is treated as a literal file name rather than the null device, causing a file named NUL to be created in the current working directory. Hardcode "/dev/null" instead, matching the approach used by the GitHub CLI. This delegates null-device handling to openssh, which already understands /dev/null correctly across Windows builds. Fixes #211 --- cmd/tailcat/cp.go | 2 +- cmd/tailcat/exec_e2e_test.go | 3 +-- cmd/tailcat/files_e2e_test.go | 2 +- cmd/tailcat/ssh.go | 2 +- cmd/tailcat/ssh_test.go | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/tailcat/cp.go b/cmd/tailcat/cp.go index 44ec942a9..1365a6b57 100644 --- a/cmd/tailcat/cp.go +++ b/cmd/tailcat/cp.go @@ -116,7 +116,7 @@ func clientCPMode(recursive, preserve bool, portOrIPPort, identityFile string, a argv = append(argv, "-o", "UpdateHostKeys no", "-o", "StrictHostKeyChecking no", - "-o", "UserKnownHostsFile "+os.DevNull, + "-o", "UserKnownHostsFile /dev/null", "-o", "LogLevel ERROR", "-o", "ProxyCommand="+proxyCommand, ) diff --git a/cmd/tailcat/exec_e2e_test.go b/cmd/tailcat/exec_e2e_test.go index e75b384c8..ae99a6658 100644 --- a/cmd/tailcat/exec_e2e_test.go +++ b/cmd/tailcat/exec_e2e_test.go @@ -9,7 +9,6 @@ package main import ( "context" - "os" "os/exec" "path/filepath" "strings" @@ -139,7 +138,7 @@ func TestServeSSHExec(t *testing.T) { ctx, cancel := context.WithTimeout(t.Context(), 30*time.Second) t.Cleanup(cancel) args := append([]string{ - "-F", os.DevNull, // not the developer's ssh config: ControlMaster and friends + "-F", "/dev/null", // not the developer's ssh config: ControlMaster and friends "-i", keyPath, "-o", "IdentitiesOnly yes", "-o", "UpdateHostKeys no", diff --git a/cmd/tailcat/files_e2e_test.go b/cmd/tailcat/files_e2e_test.go index fe6d8e3ba..e0bf6aba2 100644 --- a/cmd/tailcat/files_e2e_test.go +++ b/cmd/tailcat/files_e2e_test.go @@ -37,7 +37,7 @@ func runSFTPBatch(t *testing.T, e *testEnv, addr, batch string) ([]byte, error) defer cancel() cmd := exec.CommandContext(ctx, "sftp", "-o", "StrictHostKeyChecking no", - "-o", "UserKnownHostsFile "+os.DevNull, + "-o", "UserKnownHostsFile /dev/null", "-o", "LogLevel ERROR", "-o", "ProxyCommand="+proxyCommand, "-b", batchFile, diff --git a/cmd/tailcat/ssh.go b/cmd/tailcat/ssh.go index 24848e6c0..2aee032fe 100644 --- a/cmd/tailcat/ssh.go +++ b/cmd/tailcat/ssh.go @@ -134,7 +134,7 @@ func sshArgv(sshExe, proxyCommand, identityFile, sshDst string, cmdArgs []string sshExe, "-o", "UpdateHostKeys no", "-o", "StrictHostKeyChecking no", - "-o", "UserKnownHostsFile " + os.DevNull, + "-o", "UserKnownHostsFile /dev/null", "-o", "LogLevel ERROR", "-o", "ProxyCommand=" + proxyCommand, } diff --git a/cmd/tailcat/ssh_test.go b/cmd/tailcat/ssh_test.go index 2109c6e15..25fc9a8b9 100644 --- a/cmd/tailcat/ssh_test.go +++ b/cmd/tailcat/ssh_test.go @@ -142,7 +142,7 @@ func TestSSHArgv(t *testing.T) { "/usr/bin/ssh", "-o", "UpdateHostKeys no", "-o", "StrictHostKeyChecking no", - "-o", "UserKnownHostsFile " + os.DevNull, + "-o", "UserKnownHostsFile /dev/null", "-o", "LogLevel ERROR", "-o", "ProxyCommand=proxy", }