Skip to content

Commit 5e70b13

Browse files
committed
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/122879 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 8d6fc84 commit 5e70b13

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/cmd/pprof/readlineui.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ type readlineUI struct {
3434
}
3535

3636
func newReadlineUI() driver.UI {
37+
// disable readline UI in dumb terminal. (golang.org/issue/26254)
38+
if v := strings.ToLower(os.Getenv("TERM")); v == "" || v == "dumb" {
39+
return nil
40+
}
3741
// test if we can use terminal.ReadLine
3842
// that assumes operation in the raw mode.
3943
oldState, err := terminal.MakeRaw(0)

0 commit comments

Comments
 (0)