Commit 5e70b132 authored by Hana (Hyang-Ah) Kim's avatar Hana (Hyang-Ah) Kim Committed by Hyang-Ah Hana Kim

cmd/pprof: disable readline UI support for TERM=dumb

In general, dumb terminal indicates terminal with limited capability.
It may provide no support for special character sequences, e.g., no
handling of ANSI escape sequences. Its input/output handling behavior
may deviate from what's described in termios or terminfo. E.g., in
the shell in emacs, even after successfully setting the terminal to
raw mode, the terminal behaves as if it's still operating in canonical
mode since emacs is doing input processing first.

Readline support can be broken in various ways in dumb terminal mode,
so we want to disable readline or advanced UI features. The easiest
way to detect dumb terminal is to check the environment variable "TERM".

Fixes #26254

Change-Id: I6b652eb555bc03b84405aae08b0b25d111fbb8b0
Reviewed-on: https://go-review.googlesource.com/122879Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 8d6fc849
......@@ -34,6 +34,10 @@ type readlineUI struct {
}
func newReadlineUI() driver.UI {
// disable readline UI in dumb terminal. (golang.org/issue/26254)
if v := strings.ToLower(os.Getenv("TERM")); v == "" || v == "dumb" {
return nil
}
// test if we can use terminal.ReadLine
// that assumes operation in the raw mode.
oldState, err := terminal.MakeRaw(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment