Catch got passed a string in which the command substitution happened before, so it could not catch the error thrown by 'exec'. The string match for error messages afterwards was relying on an english language setting and did not even match the english error message of whoami from coreutils.
* runtest.exp (logname): Use catch around '[exec whoami]' and '[exec who am i]' correctly and use its result, not relying on english error messages. --- runtest.exp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/runtest.exp b/runtest.exp index 63a1c6e..feabfca 100644 --- a/runtest.exp +++ b/runtest.exp @@ -618,12 +618,10 @@ if { $logname eq "" } { set logname $env(LOGNAME) } else { # try getting it with whoami - catch "set logname [exec whoami]" tmp - if {[string match "*couldn't find*to execute*" $tmp]} { + if [catch {set logname [exec whoami]} tmp] { # try getting it with who am i unset tmp - catch "set logname [exec who am i]" tmp - if {[string match "*Command not found*" $tmp]} { + if [catch {set logname [exec who am i]} tmp] { send_user "ERROR: couldn't get the users login name\n" set logname "Unknown" } else { -- 2.45.1