diff options
author | Tom Tromey <tom@tromey.com> | 2023-09-15 17:24:26 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-09-29 10:55:43 -0600 |
commit | 4ebfd53de03599b73838ee339e47652ac26c37c0 (patch) | |
tree | 5990de5f860d32aa252dfb7564fbbb56179f737c /gdb/testsuite/lib/gdb.exp | |
parent | 2677a57064afd32076b85295bdc11de6e75e7e36 (diff) | |
download | binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.zip binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.tar.gz binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.tar.bz2 |
Support the NO_COLOR environment variable
I ran across this site:
https://no-color.org/
... which lobbies for tools to recognize the NO_COLOR environment
variable and disable any terminal styling when it is seen.
This patch implements this for gdb.
Regression tested on x86-64 Fedora 38.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/testsuite/lib/gdb.exp')
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 1b91794..de22da8 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6468,7 +6468,7 @@ proc default_gdb_init { test_file_name } { # This disables style output, which would interfere with many # tests. - setenv TERM "dumb" + setenv NO_COLOR sorry # This setting helps detect bugs in the Python code and doesn't # seem to have a significant downside for the tests. @@ -9238,6 +9238,25 @@ proc with_override { name override body } { return $result } +# Run BODY after setting the TERM environment variable to 'ansi', and +# unsetting the NO_COLOR environment variable. +proc with_ansi_styling_terminal { body } { + save_vars { ::env(TERM) ::env(NO_COLOR) } { + # Set environment variables to allow styling. + setenv TERM ansi + unset -nocomplain ::env(NO_COLOR) + + set code [catch {uplevel 1 $body} result] + } + + if {$code == 1} { + global errorInfo errorCode + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result + } else { + return -code $code $result + } +} + # Setup tuiterm.exp environment. To be used in test-cases instead of # "load_lib tuiterm.exp". Calls initialization function and schedules # finalization function. |