GNU bug report logs - #62982
Command-line parsing fails if parameters contain spaces

Previous Next

Package: dejagnu;

Reported by: Jacob Bachmeyer <jcb <at> gnu.org>

Date: Fri, 21 Apr 2023 02:04:01 UTC

Severity: normal

Done: Jacob Bachmeyer <jcb62281 <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62982 in the body.
You can then email your comments to 62982 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-dejagnu <at> gnu.org:
bug#62982; Package dejagnu. (Fri, 21 Apr 2023 02:04:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jacob Bachmeyer <jcb <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-dejagnu <at> gnu.org. (Fri, 21 Apr 2023 02:04:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jacob Bachmeyer <jcb <at> gnu.org>
To: bug-dejagnu <at> gnu.org
Subject: Command-line parsing fails if parameters contain spaces
Date: Thu, 20 Apr 2023 22:03:19 -0400
[Message part 1 (text/plain, inline)]
Forwarding problem report to assign a bug number to this.

In brief, the code that restores certain variables assigned as a result
of the command line arguments fails if any of those values contain
whitespace.  This is a problem becuase the --target_board option can
legitimately be a list of mulitple targets to run.

-- Jacob

[Message part 2 (message/rfc822, inline)]
From: Christoph Muellner <christoph.muellner <at> vrull.eu>
To: dejagnu <at> gnu.org,
	Jacob Bachmeyer <jcb <at> gnu.org>,
	Rob Savoye <rob <at> welcomehome.org>,
	Kito Cheng <kito.cheng <at> sifive.com>,
	Vineet Gupta <vineetg <at> rivosinc.com>
Cc: Christoph Müllner <christoph.muellner <at> vrull.eu>
Subject: [PATCH] runtest: Allow multi-word arguments
Date: Mon, 17 Apr 2023 20:35:52 +0200
From: Christoph Müllner <christoph.muellner <at> vrull.eu>

A recent change (5fafcd43) introduced a command line argument cache,
that ensures that command line arguments have a higher priority
than configuration files.

That cache uses the following code to save and restore:
    save_cmd_var:
      upvar 1 $name target_var
    restore_cmd_vars"
      uplevel 1 set $name $value

This works well unless $value becomes a multi-word string
(i.e. a string that contains spaces), because in this case
the command becomes:
    uplevel 1 set $name arg-word0 arg-word1 ...
Obviously this will trigger the following error:
    wrong # args: should be "set varName ?newValue?"
Quoting "$value" does not help, because the quotes are evaluated before
executing set.

Let's fix this by using upvar for the restore code as well:
    upvar 1 $name target_var
    set $target_var "$value"
Here, the quotes will be evaluated when executing the set command.

This has been reported in a downstream project, where this bug prevented
running the GCC regression tests when building in multilib
configuration:
    https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1201
The actual command in this report was:
    set target_list riscv-sim/-march=rv32imac/-mabi=ilp32/-mcmodel=medlow \
      riscv-sim/-march=rv32imafdc/-mabi=ilp32d/-mcmodel=medlow \
      riscv-sim/-march=rv64imac/-mabi=lp64/-mcmodel=medlow \
      riscv-sim/-march=rv64imafdc/-mabi=lp64d/-mcmod

Signed-off-by: Christoph Müllner <christoph.muellner <at> vrull.eu>
---
 runtest.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/runtest.exp b/runtest.exp
index 7c6018f..0829fda 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -432,7 +432,8 @@ namespace eval ::dejagnu::command_line {
 	variable cmd_var_list
 
 	foreach {name value} $cmd_var_list {
-	    uplevel 1 set $name $value
+	    upvar 1 $name target_var
+	    set $target_var "$value"
 	}
 	verbose "Variables set by command line arguments restored." 4
     }
-- 
2.39.2



Reply sent to jcb62281 <at> gmail.com:
You have taken responsibility. (Fri, 21 Apr 2023 02:52:01 GMT) Full text and rfc822 format available.

Notification sent to Jacob Bachmeyer <jcb <at> gnu.org>:
bug acknowledged by developer. (Fri, 21 Apr 2023 02:52:01 GMT) Full text and rfc822 format available.

Message #10 received at 62982-done <at> debbugs.gnu.org (full text, mbox):

From: Jacob Bachmeyer <jcb62281 <at> gmail.com>
To: 62982-done <at> debbugs.gnu.org
Subject: now fixed in Git master
Date: Thu, 20 Apr 2023 21:51:21 -0500
Fixed in commit c298959ef991b389b64a825f70094738c6a48780.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 19 May 2023 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.