bug#62982: Command-line parsing fails if parameters contain spaces
Jacob Bachmeyer <[email protected]> Thu, 20 Apr 2023 22:03:19 -0400
| Newsgroups | gmane.comp.sysutils.dejagnu.bugs |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-From-Line: [email protected] Mon Apr 17 14:36:14 2023 Return-path: <[email protected]> Envelope-to: [email protected] Delivery-date: Mon, 17 Apr 2023 14:36:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by fencepost.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <[email protected]>) id 1poTi2-0004Zj-S2 for [email protected]; Mon, 17 Apr 2023 14:36:14 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <[email protected]>) id 1poThn-0006eN-Mj for [email protected]; Mon, 17 Apr 2023 14:36:14 -0400 Received: by mail-ej1-x634.google.com with SMTP id u3so14733277ejj.12 for <[email protected]>; Mon, 17 Apr 2023 11:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1681756556; x=1684348556; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aW9RnYSruEPLIpUYzcdS9urOLOrxHQ2NMAhRM1SohsU=; b=V3Y1iLYcjKe7EpgDW3CjahP8MP7F72lUhKniPts40mE9jjtcxfy6emB8E8wxjBjaVJ OOLFf+t+tgjv+S4p/MSMC6ohptLsd6MUJmJ4CurFhyDrH3AOJVWj72tWkkW8NoJLInat 291dP6kS6b7Wl0WMN1pRwnlIRkah/1h5H10Elq2wgUshVDZ1bhuVnB/ZAYxxxX9TgTZD pKFu2TzfQYfMNFF1MdEANW9wRhqMQyQJAsD1ZZwUuSpJqVDCORqr9lQWcpdTcElqAO3E /nxf1PEq5TInxWiuza1qXUfOkBQx5hYJYycN8mZEziwV1jaCQhKimTb6PhjtHAQUjQZX nF8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681756556; x=1684348556; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aW9RnYSruEPLIpUYzcdS9urOLOrxHQ2NMAhRM1SohsU=; b=Nl7Cx+K7Ekv2xaaVKnBzAzhzNCE1A4ALLImpoAwVHdNq0S7t3rF1a4ewBA6EuZZqTs qNqcg+FGQmC2zL2inRb0HjBOTf/ParHVUCxREXdE22S61jFsvbTf23MyRgDyltvK6oh2 1OJsoRJK9kbNO9OwhxQi0uTJS53fy/XkSNAdY9D0C+UtAqQPsig8zEHqZebNcHxvUVuN ygmBM0WZnQkwdntwnK0jHb2zXdSbGSY2lzKpSux66tCUCHwY1ErVYQeKKfxd2gsZKPdu Dg1lUgSmVf75iKz8Z++sycx30nN+gyYTP/87UwYkHEcrr2U+M5gnuSDtz210SkFPzMYW gsHw== X-Gm-Message-State: AAQBX9d4PGhUmvZbmFUl7Zf1LLSqmuYgjVjX6QE2zPs/hi7LhaAmDtMS T0xmfgjbBQrn4sIL5iutbyCbxwy0unUeuXaGuSg= X-Google-Smtp-Source: AKy350ZztqdGAumjhOJl7wwSewrBEp1b1NDSb8/hxlqdtqAlKuuRDqPqjSEJeNWMkEIGlgrtZ3JJzg== X-Received: by 2002:a17:907:9090:b0:932:e6d5:bd7c with SMTP id ge16-20020a170907909000b00932e6d5bd7cmr7752825ejb.20.1681756555985; Mon, 17 Apr 2023 11:35:55 -0700 (PDT) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id d15-20020a056402078f00b00505034c27b9sm6113149edy.28.2023.04.17.11.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 11:35:55 -0700 (PDT) From: Christoph Muellner <[email protected]> To: [email protected], Jacob Bachmeyer <[email protected]>, Rob Savoye <[email protected]>, Kito Cheng <[email protected]>, Vineet Gupta <[email protected]> Cc: =?UTF-8?q?Christoph=20M=C3=BCllner?= <[email protected]> Subject: [PATCH] runtest: Allow multi-word arguments Date: Mon, 17 Apr 2023 20:35:52 +0200 Message-Id: <[email protected]> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::634; [email protected]; helo=mail-ej1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DKIM_VALID_EF=-0.1,SPF_HELO_NONE=0.001,SPF_PASS=-0.001,T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action From: Christoph Müllner <[email protected]> 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 <[email protected]> --- 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 --=-=-= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KQnVnLWRlamFn bnUgbWFpbGluZyBsaXN0CkJ1Zy1kZWphZ251QGdudS5vcmcKaHR0cHM6Ly9saXN0cy5nbnUub3Jn L21haWxtYW4vbGlzdGluZm8vYnVnLWRlamFnbnUK --=-=-=--