Skip to content

Commit 8cf867d

Browse files
committed
Fix format of err stack trace start
Fix formatting of error stack trace not to look for internal commands to withdraw if startup stack pattern cannot be matched.
1 parent df1cdab commit 8cf867d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modulecmd.tcl.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,10 @@ proc formatErrStackTrace {errmsg loc {cmdlist {}}} {
719719
set headstr "\n while executing\n"
720720
set splitstr "\n invoked from within\n"
721721
set splitstrlen [string length $splitstr]
722-
set aftheadidx [expr {[string length $headstr] + [string first $headstr\
723-
$errmsg]}]
722+
set aftheadidx [string first $headstr $errmsg]
723+
if {$aftheadidx != -1} {
724+
incr aftheadidx [string length $headstr]
725+
}
724726

725727
# get name of invalid command name to maintain it in error stack trace
726728
if {[string equal -length 22 {invalid command name "} $errmsg]} {
@@ -744,7 +746,7 @@ proc formatErrStackTrace {errmsg loc {cmdlist {}}} {
744746

745747
# filter out modulecmd internal references at beginning of stack
746748
set internals 1
747-
while {$internals} {
749+
while {$internals && $aftheadidx != -1} {
748750
# fetch erroneous command and its caller
749751
set stackelt [string range $errmsg $aftheadidx [string first\
750752
$splitstr $errmsg $aftheadidx]]

0 commit comments

Comments
 (0)