Subject: bug#44602: runtest fails when objdir in site.exp contains spaces.

From: Jacob Bachmeyer <[email-masked]>
Date: Thu, 12 Nov 2020 18:04:51 -0600

Robert Menteer via Bug-dejagnu via wrote:
> When the value of objdir in site.exp contains spaces (even if it’s 
> quoted) runtest fails.

This is due to using catch with quoted code fragments instead of braced 
code fragments.  The attached patch should fix the issue at least with 
runtest itself, but the full solution will require changes in many files 
in DejaGnu and we are already in the release code freeze for 1.6.3.  
This will be a known bug in 1.6.3 and should be fixed completely in 1.6.4.

-- Jacob
diff --git a/runtest.exp b/runtest.exp
index 21adcf6..c019841 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -311,7 +311,7 @@ proc load_file { args } {
 	if {! [catch {file exists $file} result] && $result} {
 	    set found 1
 	    verbose "Found $file"
-	    if { [catch "uplevel #0 source $file"] == 1 } {
+	    if { [catch {uplevel #0 source $file}] == 1 } {
 		send_error "ERROR: tcl error sourcing $file.\n"
 		global errorInfo
 		if {[info exists errorInfo]} {
@@ -346,7 +346,7 @@ proc search_and_load_file { type filelist dirlist } {
 		} else {
 		    verbose "Loading $filename"
 		}
-		if {[catch "uplevel #0 source $filename" error] == 1} {
+		if {[catch {uplevel #0 source $filename} error] == 1} {
 		    global errorInfo
 		    send_error "ERROR: tcl error sourcing $type $filename.\n$error\n"
 		    if {[info exists errorInfo]} {
@@ -613,11 +613,11 @@ if { $logname eq "" } {
 	    set logname $env(LOGNAME)
 	} else {
 	    # try getting it with whoami
-	    catch "set logname [exec whoami]" tmp
+	    catch {set logname [exec whoami]} tmp
 	    if {[string match "*couldn't find*to execute*" $tmp]} {
 		# try getting it with who am i
 		unset tmp
-		catch "set logname [exec who am i]" tmp
+		catch {set logname [exec who am i]} tmp
 		if {[string match "*Command not found*" $tmp]} {
 		    send_user "ERROR: couldn't get the users login name\n"
 		    set logname "Unknown"
@@ -823,7 +823,7 @@ if {[expr {$build_triplet eq "" && $host_triplet eq ""}]} {
 	send_error "ERROR: Couldn't find config.guess program.\n"
 	exit 1
     }
-    catch "exec $config_guess" build_triplet
+    catch {exec $config_guess} build_triplet
     switch -- $build_triplet {
 	"No uname command or uname output not recognized" -
 	"Unable to guess system type" {
@@ -1578,7 +1578,7 @@ proc runtest { test_file_name } {
 	    }
 	}
 
-	if { [catch "uplevel #0 source $test_file_name" msg] == 1 } {
+	if { [catch {uplevel #0 source $test_file_name} msg] == 1 } {
 	    # If we have a Tcl error, propagate the exit status so
 	    # that 'make' (if it invokes runtest) notices the error.
 	    global exit_status exit_error