From 1c3ae425255397cd452105e3b3998f0e39b2bcdb Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Fri, 6 Nov 2026 19:47:31 -0800 Subject: [PATCH] cmd/docker: skip the cobra mousetrap when arguments are passed On Windows, cobra checks before every command whether docker.exe was started from Explorer, to show a 'this is a command line tool' hint. The check calls syscall.Getppid and then looks the parent up by PID, and both take a snapshot of all running processes, which costs tens of milliseconds on a typical machine. A double-click never passes arguments, so only do the check when there are none. GitHub CLI does the same. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: Alexandre Zollinger Chohfi --- cmd/docker/docker.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index 9ce3b53e5bbb..433882ccb030 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -41,6 +41,12 @@ func (errCtxSignalTerminated) Error() string { } func main() { + // The mousetrap (a hint shown when docker.exe is started from Explorer) only + // applies to a double-click, which passes no arguments. Checking for it takes + // two snapshots of all running processes on Windows, so skip it otherwise. + if len(os.Args) > 1 { + cobra.MousetrapHelpText = "" + } err := dockerMain(context.Background()) if errors.As(err, &errCtxSignalTerminated{}) { os.Exit(getExitCode(err))