From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93541 invoked by alias); 11 Jun 2015 19:09:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 93514 invoked by uid 89); 11 Jun 2015 19:09:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_20,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 11 Jun 2015 19:09:33 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id BA8302EBD02 for ; Thu, 11 Jun 2015 19:09:31 +0000 (UTC) Received: from localhost (unused-10-15-17-126.yyz.redhat.com [10.15.17.126]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5BJ9U9J016396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Thu, 11 Jun 2015 15:09:31 -0400 From: Sergio Durigan Junior To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [RFA/testsuite] Regexp-escape command in capture_command_output References: <20150519221428.769.46872.stgit@valrhona.uglyboxes.com> <555BB8E7.4010906@redhat.com> X-URL: http://blog.sergiodj.net Date: Thu, 11 Jun 2015 19:09:00 -0000 In-Reply-To: <555BB8E7.4010906@redhat.com> (Keith Seitz's message of "Tue, 19 May 2015 15:27:51 -0700") Message-ID: <87twuevz8b.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00231.txt.bz2 On Tuesday, May 19 2015, Keith Seitz wrote: > Hi, > > I think this qualifies as obvious, but I thought I'd give others a > chance to comment... > > Our library procedure capture_command_output will fail if the given > command contains any regexp characters, such as "+" or "*". I noticed > this while writing a test which attempts to call: > > set xyz [capture_command_output "list +,-" ""] Ouch :-/. I've seen that before... > Because COMMAND is not escaped, gdb_test_multiple will generate a false > FAIL. This simple fix corrects that oversight. > > testsuite/ChangeLog > > * lib/gdb.exp (capture_command_output): Regexp-escape `command' > before using in the matching pattern. > > On 05/19/2015 03:14 PM, Keith Seitz wrote: >> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp >> index 73e55e3..fe7dd60 100644 >> --- a/gdb/testsuite/lib/gdb.exp >> +++ b/gdb/testsuite/lib/gdb.exp >> @@ -5185,7 +5185,7 @@ proc capture_command_output { command prefix } { >> >> set output_string "" >> gdb_test_multiple "$command" "capture_command_output for $command" { >> - -re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" { >> + -re "[string_to_regexp ${command}]\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" { >> set output_string $expect_out(1,string) The patch looks correct, but shouldn't we convert ${prefix} to regexp as well? Otherwise, looks good to me. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/