From 08b06194fe476b7ba821d9e27e6249a06f7f906b Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 6 Feb 2024 14:20:24 -0500 Subject: [PATCH] Revert "Merge pull request #2882 from ActiveState/mitchell/dx-2214-2" This reverts commit 137a5d7ea1ae490a1b5064f563d994e68598aa8a, reversing changes made to 94b88113690f93da2bc2d3ba737f58e9a3c2ffa8. --- cmd/state/main.go | 7 ---- internal/runbits/activation/activation.go | 2 -- internal/runbits/runtime/progress/progress.go | 2 +- internal/subshell/bash/bash.go | 15 --------- internal/subshell/cmd/cmd.go | 9 ------ internal/subshell/fish/fish.go | 16 ---------- internal/subshell/subshell.go | 6 ---- internal/subshell/tcsh/tcsh.go | 16 ---------- internal/subshell/termecho/termecho.go | 20 ------------ internal/subshell/termecho/termecho_darwin.go | 6 ---- internal/subshell/termecho/termecho_linux.go | 6 ---- internal/subshell/termecho/termecho_unix.go | 32 ------------------- .../subshell/termecho/termecho_windows.go | 30 ----------------- internal/subshell/zsh/zsh.go | 16 ---------- 14 files changed, 1 insertion(+), 182 deletions(-) delete mode 100644 internal/subshell/termecho/termecho.go delete mode 100644 internal/subshell/termecho/termecho_darwin.go delete mode 100644 internal/subshell/termecho/termecho_linux.go delete mode 100644 internal/subshell/termecho/termecho_unix.go delete mode 100644 internal/subshell/termecho/termecho_windows.go diff --git a/cmd/state/main.go b/cmd/state/main.go index 11f73c7dea..b53785706b 100644 --- a/cmd/state/main.go +++ b/cmd/state/main.go @@ -207,13 +207,6 @@ func run(args []string, isInteractive bool, cfg *config.Instance, out output.Out // Set up conditional, which accesses a lot of primer data sshell := subshell.New(cfg) - if isInteractive { - // Disable terminal echo while State Tool is running. - // Other than in prompts and subshells (which temporarily re-enable echo), user typing should - // not interfere with output (e.g. runtime progress bars). - sshell.TurnOffEcho() - defer sshell.TurnOnEcho() - } conditional := constraints.NewPrimeConditional(auth, pj, sshell.Shell()) project.RegisterConditional(conditional) diff --git a/internal/runbits/activation/activation.go b/internal/runbits/activation/activation.go index 4cb7585648..d6d23740d8 100644 --- a/internal/runbits/activation/activation.go +++ b/internal/runbits/activation/activation.go @@ -67,8 +67,6 @@ func ActivateAndWait( if err := ss.Activate(proj, cfg, out); err != nil { return locale.WrapError(err, "error_could_not_activate_subshell", "Could not activate a new subshell.") } - ss.TurnOnEcho() // temporarily re-enable echo while the subshell is active - defer ss.TurnOffEcho() a, err := process.NewActivation(cfg, os.Getpid()) if err != nil { diff --git a/internal/runbits/runtime/progress/progress.go b/internal/runbits/runtime/progress/progress.go index 786336b807..2a08b5ca74 100644 --- a/internal/runbits/runtime/progress/progress.go +++ b/internal/runbits/runtime/progress/progress.go @@ -7,6 +7,7 @@ import ( "sync" "time" + "github.com/ActiveState/cli/internal/multilog" "github.com/go-openapi/strfmt" "github.com/vbauerster/mpb/v7" "golang.org/x/net/context" @@ -14,7 +15,6 @@ import ( "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/locale" "github.com/ActiveState/cli/internal/logging" - "github.com/ActiveState/cli/internal/multilog" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/pkg/platform/runtime/artifact" "github.com/ActiveState/cli/pkg/platform/runtime/setup/events" diff --git a/internal/subshell/bash/bash.go b/internal/subshell/bash/bash.go index 08eb86e4a9..56fe481681 100644 --- a/internal/subshell/bash/bash.go +++ b/internal/subshell/bash/bash.go @@ -15,7 +15,6 @@ import ( "github.com/ActiveState/cli/internal/osutils/user" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/subshell/sscommon" - "github.com/ActiveState/cli/internal/subshell/termecho" "github.com/ActiveState/cli/pkg/project" ) @@ -220,17 +219,3 @@ func (v *SubShell) IsAvailable() bool { } return fileutils.FileExists(rcFile) } - -func (v *SubShell) TurnOffEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.Off() -} - -func (v *SubShell) TurnOnEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.On() -} diff --git a/internal/subshell/cmd/cmd.go b/internal/subshell/cmd/cmd.go index 761c35e974..f5eff62499 100644 --- a/internal/subshell/cmd/cmd.go +++ b/internal/subshell/cmd/cmd.go @@ -12,7 +12,6 @@ import ( "github.com/ActiveState/cli/internal/osutils" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/subshell/sscommon" - "github.com/ActiveState/cli/internal/subshell/termecho" "github.com/ActiveState/cli/pkg/project" ) @@ -204,11 +203,3 @@ func (v *SubShell) IsActive() bool { func (v *SubShell) IsAvailable() bool { return runtime.GOOS == "windows" } - -func (v *SubShell) TurnOffEcho() { - termecho.Off() -} - -func (v *SubShell) TurnOnEcho() { - termecho.On() -} diff --git a/internal/subshell/fish/fish.go b/internal/subshell/fish/fish.go index c39c3ea687..e5b67007e8 100644 --- a/internal/subshell/fish/fish.go +++ b/internal/subshell/fish/fish.go @@ -5,7 +5,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "github.com/ActiveState/cli/internal/constants" "github.com/ActiveState/cli/internal/errs" @@ -15,7 +14,6 @@ import ( "github.com/ActiveState/cli/internal/osutils/user" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/subshell/sscommon" - "github.com/ActiveState/cli/internal/subshell/termecho" "github.com/ActiveState/cli/pkg/project" ) @@ -197,17 +195,3 @@ func (v *SubShell) IsAvailable() bool { } return fileutils.FileExists(rcFile) } - -func (v *SubShell) TurnOffEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.Off() -} - -func (v *SubShell) TurnOnEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.On() -} diff --git a/internal/subshell/subshell.go b/internal/subshell/subshell.go index 4482fdf87a..f7eb826b9f 100644 --- a/internal/subshell/subshell.go +++ b/internal/subshell/subshell.go @@ -84,12 +84,6 @@ type SubShell interface { // IsAvailable returns whether the shell is available on the system IsAvailable() bool - - // TurnOffEcho turns off input echoing. - TurnOffEcho() - - // TurnOnEcho turns on input echoing. - TurnOnEcho() } // New returns the subshell relevant to the current process, but does not activate it diff --git a/internal/subshell/tcsh/tcsh.go b/internal/subshell/tcsh/tcsh.go index 036d909890..fed9eb9c2a 100644 --- a/internal/subshell/tcsh/tcsh.go +++ b/internal/subshell/tcsh/tcsh.go @@ -4,7 +4,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "github.com/ActiveState/cli/internal/errs" "github.com/ActiveState/cli/internal/fileutils" @@ -14,7 +13,6 @@ import ( "github.com/ActiveState/cli/internal/osutils/user" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/subshell/sscommon" - "github.com/ActiveState/cli/internal/subshell/termecho" "github.com/ActiveState/cli/pkg/project" ) @@ -191,17 +189,3 @@ func (v *SubShell) IsAvailable() bool { } return fileutils.FileExists(rcFile) } - -func (v *SubShell) TurnOffEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.Off() -} - -func (v *SubShell) TurnOnEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.On() -} diff --git a/internal/subshell/termecho/termecho.go b/internal/subshell/termecho/termecho.go deleted file mode 100644 index 5fc36e17b8..0000000000 --- a/internal/subshell/termecho/termecho.go +++ /dev/null @@ -1,20 +0,0 @@ -package termecho - -import ( - "github.com/ActiveState/cli/internal/errs" - "github.com/ActiveState/cli/internal/multilog" -) - -func Off() { - err := toggle(false) - if err != nil { - multilog.Error("Unable to turn off terminal echoing: %v", errs.JoinMessage(err)) - } -} - -func On() { - err := toggle(true) - if err != nil { - multilog.Error("Unable to turn off terminal echoing: %v", errs.JoinMessage(err)) - } -} diff --git a/internal/subshell/termecho/termecho_darwin.go b/internal/subshell/termecho/termecho_darwin.go deleted file mode 100644 index 30dedb72d5..0000000000 --- a/internal/subshell/termecho/termecho_darwin.go +++ /dev/null @@ -1,6 +0,0 @@ -package termecho - -import "golang.org/x/sys/unix" - -const ioctlReadTermios = unix.TIOCGETA -const ioctlWriteTermios = unix.TIOCSETA diff --git a/internal/subshell/termecho/termecho_linux.go b/internal/subshell/termecho/termecho_linux.go deleted file mode 100644 index 3bc972354e..0000000000 --- a/internal/subshell/termecho/termecho_linux.go +++ /dev/null @@ -1,6 +0,0 @@ -package termecho - -import "golang.org/x/sys/unix" - -const ioctlReadTermios = unix.TCGETS -const ioctlWriteTermios = unix.TCSETS diff --git a/internal/subshell/termecho/termecho_unix.go b/internal/subshell/termecho/termecho_unix.go deleted file mode 100644 index 2b04217ec3..0000000000 --- a/internal/subshell/termecho/termecho_unix.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build linux || darwin -// +build linux darwin - -package termecho - -import ( - "os" - - "github.com/ActiveState/cli/internal/errs" - "golang.org/x/sys/unix" -) - -func toggle(on bool) error { - fd := int(os.Stdin.Fd()) - termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios) - if err != nil { - return errs.Wrap(err, "Could not get termios") - } - - newState := *termios // copy - if !on { - newState.Lflag &^= unix.ECHO - } else { - newState.Lflag |= unix.ECHO - } - err = unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState) - if err != nil { - return errs.Wrap(err, "Could not set termios") - } - - return nil -} diff --git a/internal/subshell/termecho/termecho_windows.go b/internal/subshell/termecho/termecho_windows.go deleted file mode 100644 index 29d3c5eb6d..0000000000 --- a/internal/subshell/termecho/termecho_windows.go +++ /dev/null @@ -1,30 +0,0 @@ -package termecho - -import ( - "os" - - "github.com/ActiveState/cli/internal/errs" - "golang.org/x/sys/windows" -) - -func toggle(on bool) error { - fd := windows.Handle(os.Stdin.Fd()) - var mode uint32 - err := windows.GetConsoleMode(fd, &mode) - if err != nil { - return errs.Wrap(err, "Error calling GetConsoleMode") - } - - newMode := mode - if !on { - newMode &^= windows.ENABLE_ECHO_INPUT - } else { - newMode |= windows.ENABLE_ECHO_INPUT - } - err = windows.SetConsoleMode(fd, newMode) - if err != nil { - return errs.Wrap(err, "Error calling SetConsoleMode") - } - - return nil -} diff --git a/internal/subshell/zsh/zsh.go b/internal/subshell/zsh/zsh.go index cbf0ae2f77..9e6870fb57 100644 --- a/internal/subshell/zsh/zsh.go +++ b/internal/subshell/zsh/zsh.go @@ -7,7 +7,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" "strings" "github.com/ActiveState/cli/internal/constants" @@ -19,7 +18,6 @@ import ( "github.com/ActiveState/cli/internal/osutils/user" "github.com/ActiveState/cli/internal/output" "github.com/ActiveState/cli/internal/subshell/sscommon" - "github.com/ActiveState/cli/internal/subshell/termecho" "github.com/ActiveState/cli/pkg/project" ) @@ -241,17 +239,3 @@ func (v *SubShell) IsAvailable() bool { } return fileutils.FileExists(rcFile) } - -func (v *SubShell) TurnOffEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.Off() -} - -func (v *SubShell) TurnOnEcho() { - if runtime.GOOS == "windows" { - return // not supported - } - termecho.On() -}