[binutils-gdb] [gdb/testsuite, Tcl 9.0] Fix error: no such variable: Term::_TERM

Tom de Vries via Gdb-cvs <[email protected]>
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7f3d680cdc6ed08e02d003a898d47db2e0920f60

commit 7f3d680cdc6ed08e02d003a898d47db2e0920f60
Author: Tom de Vries <[email protected]>
Date:   Fri Mar 20 10:13:27 2026 +0100

    [gdb/testsuite, Tcl 9.0] Fix error: no such variable: Term::_TERM
    
    With test-case gdb.base/color-prompt.exp and Tcl 9.0, I run into:
    ...
    Running gdb.base/color-prompt.exp ...
    ERROR: tcl error sourcing gdb.base/color-prompt.exp.
    ERROR: tcl error code TCL LOOKUP VARNAME Term::_TERM
    ERROR: can't read "Term::_TERM": no such variable
        while executing
    "if { $Term::_TERM != "" } {
                setenv TERM $Term::_TERM
            } elseif { [ishost *-*-*bsd*] } {
                setenv TERM ansiw
            } else {
                setenv TERM ansi
            }"
    ...
    
    Fix this by dropping the Term prefix in Term::with_tuiterm.
    
    Likewise in Term::with_term and Term::_have_bw, fixing gdb.tui/tui-mode-switch.exp.
    
    Approved-By: Tom Tromey <[email protected]>
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

Diff:
---
 gdb/testsuite/lib/tuiterm.exp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index a1c841ebcee..a03c32b3f60 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -103,9 +103,10 @@ proc Term::_ctl_0x07 {} {
 
 # Return 1 if tuiterm has the bw/auto_left_margin enabled.
 proc Term::_have_bw {} {
+    variable _TERM
     return [expr \
-		{ [string equal $Term::_TERM "ansiw"] \
-		      || [string equal $Term::_TERM "ansis"] }]
+		{ [string equal $_TERM "ansiw"] \
+		      || [string equal $_TERM "ansis"] }]
 }
 
 # Backspace.
@@ -1236,8 +1237,9 @@ proc Term::wait_for_line { regexp {pos ""} } {
 # In BODY, when using Term::with_tuiterm, use TERM instead of the default.
 
 proc Term::with_term { term body } {
-    save_vars { Term::_TERM } {
-	set Term::_TERM $term
+    variable _TERM
+    save_vars { _TERM } {
+	set _TERM $term
 	uplevel $body
     }
 }
@@ -1248,15 +1250,15 @@ proc Term::with_tuiterm {rows cols body} {
     global env stty_init
     variable _TERM
     save_vars {env(TERM) _TERM env(NO_COLOR) stty_init} {
-	if { $Term::_TERM != "" } {
-	    setenv TERM $Term::_TERM
+	if { $_TERM != "" } {
+	    setenv TERM $_TERM
 	} elseif { [ishost *-*-*bsd*] } {
 	    setenv TERM ansiw
 	} else {
 	    setenv TERM ansi
 	}
 	# Save active TERM variable.
-	set Term::_TERM $env(TERM)
+	set _TERM $env(TERM)
 
 	setenv NO_COLOR ""
 	_setup $rows $cols
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.