Fix quoting in testsuite
diff --git a/ChangeLog b/ChangeLog
index 062aba2..9a13213 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,23 @@
 	(search_and_load_file): Likewise.
 	(runtest): Likewise.
 
+	* testsuite/lib/runtest.exp (runtest_setup_nested_testsuite):
+	Quote directory names when writing nested-init.exp to ensure that
+	it will be valid Tcl if the absolute names contain whitespace.
+
+	* testsuite/report-card.all/onetest.exp: Quote object directory
+	names in shell invocations to properly handle absolute names
+	containing whitespace.
+	* testsuite/report-card.all/passes.exp
+	(run_multipass_output_test): Likewise.
+
+	* testsuite/runtest.libs/testsuite_file.test: Revise tests to
+	protect interpolations of directory variables.
+
+	* testsuite/runtest.libs/utils.test: Declare test of which
+	procedure with an absolute file name unsupported if the full
+	absolute name of the object directory contains whitespace.
+
 2026-07-03  Jacob Bachmeyer  <jcb@gnu.org>
 
 	PR44602
diff --git a/testsuite/lib/runtest.exp b/testsuite/lib/runtest.exp
index 40097b6..4f19674 100644
--- a/testsuite/lib/runtest.exp
+++ b/testsuite/lib/runtest.exp
@@ -1,4 +1,5 @@
-# Copyright (C) 1992-2016, 2018, 2020, 2021 Free Software Foundation, Inc.
+# Copyright (C) 1992-2016, 2018, 2020, 2021, 2026
+#		Free Software Foundation, Inc.
 #
 # This file is part of DejaGnu.
 #
@@ -54,10 +55,10 @@
 
     set fd [open nested-init.exp w]
     puts $fd "set host_triplet $host_triplet"
-    puts $fd "set srcdir [testsuite file -source -test nested]"
-    puts $fd "set objdir [testsuite file -object -test nested]"
-    puts $fd "set tmpdir $tmpdir"
-    puts $fd "set outdir $tmpdir"
+    puts $fd "set srcdir \"[testsuite file -source -test nested]\""
+    puts $fd "set objdir \"[testsuite file -object -test nested]\""
+    puts $fd "set tmpdir \"$tmpdir\""
+    puts $fd "set outdir \"$tmpdir\""
     close $fd
 
     if {![file isdirectory $tmpdir]} {
diff --git a/testsuite/report-card.all/onetest.exp b/testsuite/report-card.all/onetest.exp
index fbf58b9..c9aadb4 100644
--- a/testsuite/report-card.all/onetest.exp
+++ b/testsuite/report-card.all/onetest.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2018, 2024 Free Software Foundation, Inc.
+# Copyright (C) 2018, 2024, 2026 Free Software Foundation, Inc.
 #
 # This file is part of DejaGnu.
 #
@@ -40,7 +40,7 @@
 set stty_init { -onlcr }
 
 spawn /bin/sh -c \
-    "cd [testsuite file -object -test onetest]\
+    "cd \"[testsuite file -object -test onetest]\"\
      && exec $LAUNCHER report-card"
 
 # check header
@@ -172,7 +172,7 @@
 foreach name $test_names {
     set separator_count 0
     spawn /bin/sh -c \
-	"cd [testsuite file -object -test onetest]\
+	"cd \"[testsuite file -object -test onetest]\"\
 	 && exec $LAUNCHER report-card one-${name}.sum"
     # skip header
     expect {
diff --git a/testsuite/report-card.all/passes.exp b/testsuite/report-card.all/passes.exp
index 8b2e681..26234e1 100644
--- a/testsuite/report-card.all/passes.exp
+++ b/testsuite/report-card.all/passes.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2018, 2024 Free Software Foundation, Inc.
+# Copyright (C) 2018, 2024, 2026 Free Software Foundation, Inc.
 #
 # This file is part of DejaGnu.
 #
@@ -185,7 +185,7 @@
     # run the dejagnu-report-card tool
     set separator_count 0
     spawn /bin/sh -c \
-	"cd [testsuite file -object -test passes]\
+	"cd \"[testsuite file -object -test passes]\"\
 	 && exec $LAUNCHER report-card ${filetag}-*.sum"
 
     # skip header
diff --git a/testsuite/runtest.libs/testsuite_file.test b/testsuite/runtest.libs/testsuite_file.test
index 0b5dc86..23a4e3d 100644
--- a/testsuite/runtest.libs/testsuite_file.test
+++ b/testsuite/runtest.libs/testsuite_file.test
@@ -1,6 +1,6 @@
 # test "testsuite file" API call				-*- Tcl -*-
 
-# Copyright (C) 2018 Free Software Foundation, Inc.
+# Copyright (C) 2018, 2026 Free Software Foundation, Inc.
 #
 # This file is part of DejaGnu.
 #
@@ -170,11 +170,11 @@
 set testdir [file join $srcdir $subdir]
 
 run_tests [subst -nocommands {
-    { lib_ret_test testsuite { file -source -top } $srcdir
+    { lib_ret_test testsuite { file -source -top } {$srcdir}
 	"testsuite file -source -top" }
-    { lib_ret_test testsuite { file -source -test } $testdir
+    { lib_ret_test testsuite { file -source -test } {$testdir}
 	"testsuite file -source -test" }
-    { lib_ret_test testsuite { file -object -top } $objdir
+    { lib_ret_test testsuite { file -object -top } {$objdir}
 	"testsuite file -object -top" }
     { lib_errpat_test testsuite { file -source -test {[bogus]} foo }
 	"directory '*\\\\[bogus\\\\]' does not exist"
@@ -193,7 +193,7 @@
 run_tests [subst {
     { lib_ret_test testsuite
 	{ file -object -top -hypothetical empty-test-dir foo }
-	[file join $objdir empty-test-dir foo]
+	{[file join $objdir empty-test-dir foo]}
 	"testsuite file implying hypothetical directory" }
 }]
 
@@ -206,7 +206,7 @@
 run_tests [subst {
     { lib_ret_test testsuite
 	{ file -object -top empty-test-dir foo }
-	[file join $objdir empty-test-dir foo]
+	{[file join $objdir empty-test-dir foo]}
 	"testsuite file implying new object directory" }
 }]
 
diff --git a/testsuite/runtest.libs/utils.test b/testsuite/runtest.libs/utils.test
index acaed98..592d979 100644
--- a/testsuite/runtest.libs/utils.test
+++ b/testsuite/runtest.libs/utils.test
@@ -1,6 +1,6 @@
 # Test procedures in lib/utils.exp.				-*- Tcl -*-
 #
-# Copyright (C) 1996-2019, 2020 Free Software Foundation, Inc.
+# Copyright (C) 1996-2019, 2020, 2026 Free Software Foundation, Inc.
 #
 # This file is part of DejaGnu.
 #
@@ -132,7 +132,12 @@
 
 # Test 'which' using an absolute path.
 #
-if {[which [file join $objdir .. config.status]] != 0} {
+if {[regexp {[[:space:]]} $objdir]} {
+    # unfortunately, the which procedure explicitly truncates its argument
+    # at the first whitespace and ChangeLog-1992 appears to indicate that
+    # it has done so since 11 Jul 1993.
+    unsupported "which, absolute path to config.status"
+} elseif {[which [file join $objdir .. config.status]] != 0} {
   pass "which, absolute path to config.status"
 } else {
   fail "which, absolute path to config.status"