From af301bfff1ab4669e95f79067bb4aae1460f17c0 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 10 Sep 2021 17:36:20 -0400 Subject: [PATCH 1/3] stdin/stdout fds are not 0/1 on windows --- cmd/ghcs/common.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/ghcs/common.go b/cmd/ghcs/common.go index 229e04c78..b77d4a041 100644 --- a/cmd/ghcs/common.go +++ b/cmd/ghcs/common.go @@ -93,7 +93,9 @@ func getOrChooseCodespace(ctx context.Context, apiClient *api.API, user *api.Use return codespace, token, nil } -var hasTTY = term.IsTerminal(0) && term.IsTerminal(1) // is process connected to a terminal? +// hasTTY indicates whether the process connected to a terminal. +// It is not portable to assume stdin/stdout are fds 0 and 1. +var hasTTY = term.IsTerminal(os.Stdin.Fd()) && term.IsTerminal(os.Stdout.Fd()) // ask asks survey questions on the terminal, using standard options. // It fails unless hasTTY, but ideally callers should avoid calling it in that case. From 1526ab5bff3065558bbc3b40db3eb501f6e56061 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Fri, 10 Sep 2021 18:08:48 -0400 Subject: [PATCH 2/3] fix URL --- cmd/ghcs/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ghcs/common.go b/cmd/ghcs/common.go index b77d4a041..c4171acc2 100644 --- a/cmd/ghcs/common.go +++ b/cmd/ghcs/common.go @@ -109,7 +109,7 @@ func ask(qs []*survey.Question, response interface{}) error { // ASCII \x03 (ETX) instead of delivering SIGINT to the application. // So we have to serve ourselves the SIGINT. // - // https://github.com/AlecAivazis/survey/#why-isnt-sending-a-sigint-aka-ctrl-c-signal-working + // https://github.com/AlecAivazis/survey/#why-isnt-ctrl-c-working if err == terminal.InterruptErr { self, _ := os.FindProcess(os.Getpid()) _ = self.Signal(os.Interrupt) // assumes POSIX From c4be0a0e284ed1d22fc26dc452b81b56ab4549b5 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 13 Sep 2021 09:29:46 -0400 Subject: [PATCH 3/3] this time without compile errors --- cmd/ghcs/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ghcs/common.go b/cmd/ghcs/common.go index c4171acc2..bfcb67496 100644 --- a/cmd/ghcs/common.go +++ b/cmd/ghcs/common.go @@ -95,7 +95,7 @@ func getOrChooseCodespace(ctx context.Context, apiClient *api.API, user *api.Use // hasTTY indicates whether the process connected to a terminal. // It is not portable to assume stdin/stdout are fds 0 and 1. -var hasTTY = term.IsTerminal(os.Stdin.Fd()) && term.IsTerminal(os.Stdout.Fd()) +var hasTTY = term.IsTerminal(int(os.Stdin.Fd())) && term.IsTerminal(int(os.Stdout.Fd())) // ask asks survey questions on the terminal, using standard options. // It fails unless hasTTY, but ideally callers should avoid calling it in that case.