From 7dbbe0c7c70421a43df35b7b5667c8db15f31fb7 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 4 May 2021 11:00:35 -0700 Subject: [PATCH] cmd/tailscale/cli: fix running from Xcode We were over-eager in running tailscale in GUI mode. f42ded7acf63e2f3711f6512b701ddeac0e2d7a6 fixed that by checking for a variety of shell-ish env vars and using those to force us into CLI mode. However, for reasons I don't understand, those shell env vars are present when Xcode runs Tailscale.app on my machine. (I've changed no configs, modified nothing on a brand new machine.) Work around that by adding an additional "only in GUI mode" check. Signed-off-by: Josh Bleecher Snyder --- cmd/tailscale/cli/cli.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/tailscale/cli/cli.go b/cmd/tailscale/cli/cli.go index 9c5a3ab6b..ab58eb4a3 100644 --- a/cmd/tailscale/cli/cli.go +++ b/cmd/tailscale/cli/cli.go @@ -51,6 +51,14 @@ func ActLikeCLI() bool { return false } + // Xcode adds the -NSDocumentRevisionsDebugMode flag on execution. + // If present, we are almost certainly being run as a GUI. + for _, arg := range os.Args { + if arg == "-NSDocumentRevisionsDebugMode" { + return false + } + } + // Looking at the environment of the GUI Tailscale app (ps eww // $PID), empirically none of these environment variables are // present. But all or some of these should be present with