]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite, Tcl 9.0] Fix error: no such variable: Term::_TERM
authorTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
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 <tom@tromey.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33948

gdb/testsuite/lib/tuiterm.exp

index a1c841ebceebc73aea57b972f1eb77abd6d80df4..a03c32b3f602150744df614c51c86c6d999828cf 100644 (file)
@@ -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