From unknown Sat Aug 09 19:20:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52873: expr unexpected syntax error Resent-From: Martin Rixham Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 Dec 2021 16:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 52873 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 52873@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.164079440322190 (code B ref -1); Wed, 29 Dec 2021 16:14:02 +0000 Received: (at submit) by debbugs.gnu.org; 29 Dec 2021 16:13:23 +0000 Received: from localhost ([127.0.0.1]:50051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2bZq-0005lo-Ki for submit@debbugs.gnu.org; Wed, 29 Dec 2021 11:13:23 -0500 Received: from lists.gnu.org ([209.51.188.17]:35224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2YHy-0000wp-AL for submit@debbugs.gnu.org; Wed, 29 Dec 2021 07:42:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2YHx-0005dF-65 for bug-coreutils@gnu.org; Wed, 29 Dec 2021 07:42:41 -0500 Received: from [2a00:1450:4864:20::52b] (port=35484 helo=mail-ed1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2YHv-0002hE-8r for bug-coreutils@gnu.org; Wed, 29 Dec 2021 07:42:40 -0500 Received: by mail-ed1-x52b.google.com with SMTP id y22so85894774edq.2 for ; Wed, 29 Dec 2021 04:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=equalexperts-com.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Ov6v2Y5UajZn0tqhkJAIBtCr2cm7C4VOr8w4LK5EfNs=; b=w9WOFW9YK+rLTNx/tkhxMj+Xy8xF5LkNsnlvqbLi8skN7UH/QPr5d6IZRseD7bbdE3 6p9z0xhtPH2JnkhqG2YgVXihieNU9xkZ72c8rzSfmo1uXsGagbz+/9GoE5tCWaZ/1q30 YI3R36yLpIdqpJppzpSAxTjDzmOHobLUd+UtykuBjey94Ez9RQmPqGv/xFqU1YywkLc6 rGGfdPxzNSxly8xO5Okg3O5ZvSutSGbxxDcfPJ2RqWd40UvNUXV+5pKWxCcl3UhbxIv3 g4hN/OntWkQeNA84kIJ9xRBws0yYv2xzU9lkwXrWzvxFAW3gL5ourTsENM3JZ9sRTbv8 zASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Ov6v2Y5UajZn0tqhkJAIBtCr2cm7C4VOr8w4LK5EfNs=; b=vjgNvoi48nNLsgmxToT4VLTmRMy0VqBFkQFgtu+4Fa2ZAbwy7HMTfDiptLRz1CBSDt 88HIZ+oszWcW9ykNimhMWapLlPf59uKIi8aSeAX+shDs3G+3lL04TCt6brRgt8LSorxU K0J118acvMrYrZLS+caqv9Imn57MdezzZ6VlVmu8ffcCgwe6GOWuXZY6Rp6Ppcxa8cW2 cYtqaCIEvpNiF3VFEHoTnvC6p+s2Q4v7TMK2UxcMqLWMT0KG7jECirIRKdI6XOX3C/6u iJ+CGEf3j2K5+xVaU6xhf2pczMJ5OS2Ua3HYt2JtNME3rlQS/CyFndxbPe+EH3txMj6S bQbA== X-Gm-Message-State: AOAM533am9tOT9XjR3Zymf0D4/jph6Ce5cG0wyL8tqn6kOC9S0m+G0IL jL3JO2NGnelfsKX9+Q8N9X+37aO1JvNi949QvSXrMOH7zWE= X-Google-Smtp-Source: ABdhPJzi8RHErKn7mJI5n/X02/mGL/nOdVkncfnq0qBhONtNvOMPWr0hg8PkrhiBbQo+UfjBl3B8lcVBqzBKSB6J9U4= X-Received: by 2002:a05:6402:42c1:: with SMTP id i1mr25782553edc.12.1640781755401; Wed, 29 Dec 2021 04:42:35 -0800 (PST) MIME-Version: 1.0 From: Martin Rixham Date: Wed, 29 Dec 2021 12:42:24 +0000 Message-ID: Content-Type: multipart/alternative; boundary="000000000000af582b05d44845fe" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=martin.rixham@equalexperts.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Wed, 29 Dec 2021 11:13:22 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000af582b05d44845fe Content-Type: text/plain; charset="UTF-8" I'm getting an error from the following: [martin@fedora ~]$ expr ')' : '.*' expr: syntax error: unexpected ')' There also seems to be a similar problem with: expr '(' : '.*' Here's the version: [martin@fedora ~]$ expr --version expr (GNU coreutils) 8.32 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later < https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Parker, James Youngman, and Paul Eggert. And a uname for good measure: [martin@fedora ~]$ uname -a Linux fedora 5.15.7-200.fc35.x86_64 #1 SMP Wed Dec 8 19:00:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Thanks, Martin --000000000000af582b05d44845fe Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm getting an error from the following:

=C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ expr ')' : &= #39;.*'
=C2=A0=C2=A0=C2=A0 expr: syntax error: unexpected ')'= ;

There also seems to be a similar problem with:

=C2=A0=C2=A0=C2=A0 expr '(' : '.*'<= /div>

Here's the version:

= =C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ expr --version
=C2=A0=C2=A0=C2=A0= expr (GNU coreutils) 8.32
=C2=A0=C2=A0=C2=A0 Copyright (C) 2020 Free So= ftware Foundation, Inc.
=C2=A0=C2=A0=C2=A0 License GPLv3+: GNU GPL versi= on 3 or later <https://gnu.org/licenses/gpl.html>.
=C2=A0=C2=A0=C2=A0 Thi= s is free software: you are free to change and redistribute it.
=C2=A0= =C2=A0=C2=A0 There is NO WARRANTY, to the extent permitted by law.

= =C2=A0=C2=A0=C2=A0 Written by Mike Parker, James Youngman, and Paul Eggert.=

And a uname for good measure:

=C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ uname -a
=C2=A0=C2=A0=C2=A0= Linux fedora 5.15.7-200.fc35.x86_64 #1 SMP Wed Dec 8 19:00:47 UTC 2021 x86= _64 x86_64 x86_64 GNU/Linux

Thanks,

=
Martin
--000000000000af582b05d44845fe-- From unknown Sat Aug 09 19:20:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52873: expr unexpected syntax error Resent-From: Davide Brini Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 Dec 2021 16:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52873 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 52873@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16407955005670 (code B ref -1); Wed, 29 Dec 2021 16:32:01 +0000 Received: (at submit) by debbugs.gnu.org; 29 Dec 2021 16:31:40 +0000 Received: from localhost ([127.0.0.1]:50090 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2brX-0001TD-Hc for submit@debbugs.gnu.org; Wed, 29 Dec 2021 11:31:39 -0500 Received: from lists.gnu.org ([209.51.188.17]:47542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2brV-0001RM-F2 for submit@debbugs.gnu.org; Wed, 29 Dec 2021 11:31:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2brV-0001La-6v for bug-coreutils@gnu.org; Wed, 29 Dec 2021 11:31:37 -0500 Received: from mout.gmx.net ([212.227.17.22]:40341) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2brT-0003Wg-Ek for bug-coreutils@gnu.org; Wed, 29 Dec 2021 11:31:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1640795492; bh=hHlUJ9PeGVoRh09ej4woU/WAT6S4LVOF1ZVifG6Sg7M=; h=X-UI-Sender-Class:Date:From:To:Subject:In-Reply-To:References; b=JPJZjySv9DRu3piFKOJNvIi7NNmRunbNwBtLABCv9Quwr5DGscRGYVm50E60PgKko fWot8THA+9/n5fuGPp2WlEdpGl4NX/tv/4owaUrf29G39zJkTGkWkMOj0DosnNKc80 obKabo75senk++dC9r4zobNc1Tc6NznezCB6yz58= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from swedishchef ([80.104.178.89]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1M3DJl-1mzZST24XF-003enZ for ; Wed, 29 Dec 2021 17:31:32 +0100 Date: Wed, 29 Dec 2021 17:31:31 +0100 From: Davide Brini Message-ID: <20211229173131.560e0680@swedishchef> In-Reply-To: References: X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:X005Cl3LRXOpGlMs57XzC9yOtyN9t6jWr0sZIf+g4y6HJ9C4Agh h8Hl2PtXAo8hBYbGGhWyTYWau/fMA8TizTKzRo0yJ96N4MeO3V+EegrKTY97QexvBEq2BIE TrH5dN+IWnqK+1hERBBXGwaalKPxY6DyoX70lpUsLBHl+cpV3UHkt03wLbVCWO/F4W0gwWY 9z1kEPGvUyLRSymxygFGQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:xqOdVztlecw=:xb3MUYOgx9+PjU9vG29T6D yvX9zn5gR3ENb0f4FhaZ6uLWag+TLqscyNmyldhRGi1ZQ23FofGikfy/rDxvTamqudJCfuFJX BFz2bncak32/vBa7TfqQN22QJbPHhZuB8c1+S8/S3lVRnMWOlsg5JirzReHDhCQh8p0vTqQc5 mTxjSEk4nNMTfHvdlNWXX73LYAV1Pnapx58OA4hKL/AyNF5FkaGt2JBJRJvzgVxGYa3uZXPgL saLd+DpnwWefkNKhgsE1Wv0CxOwFYjJFm75qOatduEIBbStPjNvMIQOb/GoUpdzEKl7nbT9sB O6fIpoNYLwum5TtNzxMlHDek6WYPLzhyGNpNLmiLERPu3KMiwA8r4wXg/FHjE9yZOzwb6u0FT plZKKX/9MjjJJplnAKTnm3jS43k/fA74qeTgZkIpF3ePawuP4HxuTgQASJ8HdQNB7ab+7C5v8 f0VxQxJmnEw2kQOYnc5ojOdynispEQ9ySZSvj2OpFEG2cdGOoZrixIPGu6sA5JuN3GkIYtedq kCq9BZQl8q4Wq0vksLHEdpH8v2u1UMtk8wInGk0cuJD3WpGbXgswEdn2wkWlrOgfryMrIiqYJ NY8simovyESvIIbCmtFNnYsu38ff1EBnQpXSKw1ZaS56NpBeFPHP6tmHEsmRpV3ovadkgErbf ANQQoL4o9x5vQI5Y6L8Z790jR6f1NQRuuvqjByao2JYhdHRV/3tDhJxVDoKf4TUbwl/8iq3l6 srQNsHIksUfY7BzAWRBVbmMECtFvENul1zBu3gsim07zQRokq6hQEjXN5KyPExwpHRespocH+ C1v/AR+6XSIIZzUiDXkH0nq5y7Q5+yKH5HXdf/CORxuRn0YJePUUhREv1YqxCSVC4jrBZsb13 lOevfJr4FcOqN34lo2i298IICLumCaGRci5x4JcW60hYkW6RONXK9+WeAh1qEO7HAbH4UFEbR EFH0PMqkXzdk6lR0tn5XnHmKT+IW8SItuN/TqdjnClOziroSkv9tM2xurUBTsKJum4VwkjbHm OgQs4EKgFxIY2qT9ZV8/FwYJtkJvFew1weehaYy135pg4fsD9P/t8D3Fqr/AKQi2YAR8TdtOF mgKJd91fOymHF0= Received-SPF: pass client-ip=212.227.17.22; envelope-from=dave_br@gmx.com; helo=mout.gmx.net X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) On Wed, 29 Dec 2021 12:42:24 +0000, Martin Rixham wrote: > I'm getting an error from the following: > > [martin@fedora ~]$ expr ')' : '.*' > expr: syntax error: unexpected ')' > > There also seems to be a similar problem with: > > expr '(' : '.*' I think you need to use '+' before the offending token, at least according to the man page: + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' And indeed: $ expr '+' ')' : '.*' 1 =2D- D. From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 29 14:52:18 2021 Received: (at control) by debbugs.gnu.org; 29 Dec 2021 19:52:19 +0000 Received: from localhost ([127.0.0.1]:50415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ezi-0000Os-PY for submit@debbugs.gnu.org; Wed, 29 Dec 2021 14:52:18 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ezg-0000Oc-BI for control@debbugs.gnu.org; Wed, 29 Dec 2021 14:52:17 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 02E491600FC for ; Wed, 29 Dec 2021 11:52:10 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sofA7kBGSLHQ for ; Wed, 29 Dec 2021 11:52:09 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6CB1A160142 for ; Wed, 29 Dec 2021 11:52:09 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jAC1fJbVIZTX for ; Wed, 29 Dec 2021 11:52:09 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4959A1600FC for ; Wed, 29 Dec 2021 11:52:09 -0800 (PST) Message-ID: Date: Wed, 29 Dec 2021 11:52:08 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US To: control@debbugs.gnu.org From: Paul Eggert Subject: 52873 is not a bug Organization: UCLA Computer Science Department Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 52873 notabug From unknown Sat Aug 09 19:20:40 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Martin Rixham Subject: bug#52873: closed (Re: bug#52873: expr unexpected syntax error) Message-ID: References: <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> X-Gnu-PR-Message: they-closed 52873 X-Gnu-PR-Package: coreutils X-Gnu-PR-Keywords: notabug Reply-To: 52873@debbugs.gnu.org Date: Wed, 29 Dec 2021 19:53:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1640807582-1631-1" This is a multi-part message in MIME format... ------------=_1640807582-1631-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #52873: expr unexpected syntax error which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 52873@debbugs.gnu.org. --=20 52873: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D52873 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1640807582-1631-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 52873-done) by debbugs.gnu.org; 29 Dec 2021 19:52:35 +0000 Received: from localhost ([127.0.0.1]:50418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ezy-0000PQ-Va for submit@debbugs.gnu.org; Wed, 29 Dec 2021 14:52:35 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2ezw-0000PB-NH for 52873-done@debbugs.gnu.org; Wed, 29 Dec 2021 14:52:33 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 544C31600FC; Wed, 29 Dec 2021 11:52:27 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id UBD6w4lanuI0; Wed, 29 Dec 2021 11:52:26 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7F943160142; Wed, 29 Dec 2021 11:52:26 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mIFC4Nb26bAf; Wed, 29 Dec 2021 11:52:26 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 4EF151600FC; Wed, 29 Dec 2021 11:52:26 -0800 (PST) Message-ID: <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> Date: Wed, 29 Dec 2021 11:52:25 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Subject: Re: bug#52873: expr unexpected syntax error Content-Language: en-US To: Davide Brini References: <20211229173131.560e0680@swedishchef> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <20211229173131.560e0680@swedishchef> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 52873-done Cc: Martin Rixham , 52873-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 12/29/21 08:31, Davide Brini wrote: > I think you need to use '+' before the offending token Yes. That's a GNU extension. If you want to be portable to any POSIX implementation, you can use this instead: expr "X(" : '.*' - 1 A similar example is given in the POSIX spec for 'expr': https://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html As this is not a bug, I'm closing the bug report. ------------=_1640807582-1631-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Dec 2021 16:13:23 +0000 Received: from localhost ([127.0.0.1]:50051 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2bZq-0005lo-Ki for submit@debbugs.gnu.org; Wed, 29 Dec 2021 11:13:23 -0500 Received: from lists.gnu.org ([209.51.188.17]:35224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2YHy-0000wp-AL for submit@debbugs.gnu.org; Wed, 29 Dec 2021 07:42:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n2YHx-0005dF-65 for bug-coreutils@gnu.org; Wed, 29 Dec 2021 07:42:41 -0500 Received: from [2a00:1450:4864:20::52b] (port=35484 helo=mail-ed1-x52b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n2YHv-0002hE-8r for bug-coreutils@gnu.org; Wed, 29 Dec 2021 07:42:40 -0500 Received: by mail-ed1-x52b.google.com with SMTP id y22so85894774edq.2 for ; Wed, 29 Dec 2021 04:42:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=equalexperts-com.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Ov6v2Y5UajZn0tqhkJAIBtCr2cm7C4VOr8w4LK5EfNs=; b=w9WOFW9YK+rLTNx/tkhxMj+Xy8xF5LkNsnlvqbLi8skN7UH/QPr5d6IZRseD7bbdE3 6p9z0xhtPH2JnkhqG2YgVXihieNU9xkZ72c8rzSfmo1uXsGagbz+/9GoE5tCWaZ/1q30 YI3R36yLpIdqpJppzpSAxTjDzmOHobLUd+UtykuBjey94Ez9RQmPqGv/xFqU1YywkLc6 rGGfdPxzNSxly8xO5Okg3O5ZvSutSGbxxDcfPJ2RqWd40UvNUXV+5pKWxCcl3UhbxIv3 g4hN/OntWkQeNA84kIJ9xRBws0yYv2xzU9lkwXrWzvxFAW3gL5ourTsENM3JZ9sRTbv8 zASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Ov6v2Y5UajZn0tqhkJAIBtCr2cm7C4VOr8w4LK5EfNs=; b=vjgNvoi48nNLsgmxToT4VLTmRMy0VqBFkQFgtu+4Fa2ZAbwy7HMTfDiptLRz1CBSDt 88HIZ+oszWcW9ykNimhMWapLlPf59uKIi8aSeAX+shDs3G+3lL04TCt6brRgt8LSorxU K0J118acvMrYrZLS+caqv9Imn57MdezzZ6VlVmu8ffcCgwe6GOWuXZY6Rp6Ppcxa8cW2 cYtqaCIEvpNiF3VFEHoTnvC6p+s2Q4v7TMK2UxcMqLWMT0KG7jECirIRKdI6XOX3C/6u iJ+CGEf3j2K5+xVaU6xhf2pczMJ5OS2Ua3HYt2JtNME3rlQS/CyFndxbPe+EH3txMj6S bQbA== X-Gm-Message-State: AOAM533am9tOT9XjR3Zymf0D4/jph6Ce5cG0wyL8tqn6kOC9S0m+G0IL jL3JO2NGnelfsKX9+Q8N9X+37aO1JvNi949QvSXrMOH7zWE= X-Google-Smtp-Source: ABdhPJzi8RHErKn7mJI5n/X02/mGL/nOdVkncfnq0qBhONtNvOMPWr0hg8PkrhiBbQo+UfjBl3B8lcVBqzBKSB6J9U4= X-Received: by 2002:a05:6402:42c1:: with SMTP id i1mr25782553edc.12.1640781755401; Wed, 29 Dec 2021 04:42:35 -0800 (PST) MIME-Version: 1.0 From: Martin Rixham Date: Wed, 29 Dec 2021 12:42:24 +0000 Message-ID: Subject: expr unexpected syntax error To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary="000000000000af582b05d44845fe" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52b (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=martin.rixham@equalexperts.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 29 Dec 2021 11:13:22 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000af582b05d44845fe Content-Type: text/plain; charset="UTF-8" I'm getting an error from the following: [martin@fedora ~]$ expr ')' : '.*' expr: syntax error: unexpected ')' There also seems to be a similar problem with: expr '(' : '.*' Here's the version: [martin@fedora ~]$ expr --version expr (GNU coreutils) 8.32 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later < https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Parker, James Youngman, and Paul Eggert. And a uname for good measure: [martin@fedora ~]$ uname -a Linux fedora 5.15.7-200.fc35.x86_64 #1 SMP Wed Dec 8 19:00:47 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Thanks, Martin --000000000000af582b05d44845fe Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm getting an error from the following:

=C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ expr ')' : &= #39;.*'
=C2=A0=C2=A0=C2=A0 expr: syntax error: unexpected ')'= ;

There also seems to be a similar problem with:

=C2=A0=C2=A0=C2=A0 expr '(' : '.*'<= /div>

Here's the version:

= =C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ expr --version
=C2=A0=C2=A0=C2=A0= expr (GNU coreutils) 8.32
=C2=A0=C2=A0=C2=A0 Copyright (C) 2020 Free So= ftware Foundation, Inc.
=C2=A0=C2=A0=C2=A0 License GPLv3+: GNU GPL versi= on 3 or later <https://gnu.org/licenses/gpl.html>.
=C2=A0=C2=A0=C2=A0 Thi= s is free software: you are free to change and redistribute it.
=C2=A0= =C2=A0=C2=A0 There is NO WARRANTY, to the extent permitted by law.

= =C2=A0=C2=A0=C2=A0 Written by Mike Parker, James Youngman, and Paul Eggert.=

And a uname for good measure:

=C2=A0=C2=A0=C2=A0 [martin@fedora ~]$ uname -a
=C2=A0=C2=A0=C2=A0= Linux fedora 5.15.7-200.fc35.x86_64 #1 SMP Wed Dec 8 19:00:47 UTC 2021 x86= _64 x86_64 x86_64 GNU/Linux

Thanks,

=
Martin
--000000000000af582b05d44845fe-- ------------=_1640807582-1631-1-- From unknown Sat Aug 09 19:20:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52873: expr unexpected syntax error Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 Dec 2021 20:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52873 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: notabug To: Martin Rixham Cc: 52873-done@debbugs.gnu.org, Davide Brini Received: via spool by 52873-done@debbugs.gnu.org id=D52873.164081149017151 (code D ref 52873); Wed, 29 Dec 2021 20:59:02 +0000 Received: (at 52873-done) by debbugs.gnu.org; 29 Dec 2021 20:58:10 +0000 Received: from localhost ([127.0.0.1]:50457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2g1S-0004SZ-0t for submit@debbugs.gnu.org; Wed, 29 Dec 2021 15:58:10 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2g1P-0004S5-JP for 52873-done@debbugs.gnu.org; Wed, 29 Dec 2021 15:58:08 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 398DA1600FC; Wed, 29 Dec 2021 12:58:01 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 73Him2C8N5Is; Wed, 29 Dec 2021 12:58:00 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7EB82160142; Wed, 29 Dec 2021 12:58:00 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id iR5V2ky-3ZNM; Wed, 29 Dec 2021 12:58:00 -0800 (PST) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 547811600FC; Wed, 29 Dec 2021 12:58:00 -0800 (PST) Message-ID: Date: Wed, 29 Dec 2021 12:57:59 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.1 Content-Language: en-US References: <20211229173131.560e0680@swedishchef> <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.4 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) On 12/29/21 12:01, Martin Rixham wrote: > What nonsense. I want to parse source code. ')' is not an uncommon line of > source code. It should work. Unfortunately, you're asking for what is in general impossible. If the left argument of ':' could be any string, then the grammar for 'expr' would be ambiguous. Consider the following shell command: expr '(' : ')' This outputs ':' because it evaluates the parenthesized string ':'; but if the operands of ':' could be any strings it could also be interpreted as matching '(' against ')', which means it should output the same thing as 'expr a : b', namely '0'. Of course this means 'expr' was poorly designed in the 1970s, but we're stuck with that design now (it's standardized by POSIX), portable code must deal with this poor design, and for compatibility reasons it's better for GNU expr to support the design, poor as it is. These days there are much better ways than 'expr' to parse code. For example, if you want to count the number of characters in a shell variable v, you can use this shell command: nv=${#v} This works even if v=')', whereas this: nv=$(expr "$v" : '.*') has the bug that you mentioned, plus it's harder to read and it's less efficient. From unknown Sat Aug 09 19:20:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52873: expr unexpected syntax error Resent-From: Martin Rixham Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 Dec 2021 21:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52873 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: notabug To: Paul Eggert Cc: 52873-done@debbugs.gnu.org, Davide Brini Received: via spool by 52873-done@debbugs.gnu.org id=D52873.164081159317328 (code D ref 52873); Wed, 29 Dec 2021 21:00:02 +0000 Received: (at 52873-done) by debbugs.gnu.org; 29 Dec 2021 20:59:53 +0000 Received: from localhost ([127.0.0.1]:50460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2g36-0004VP-CJ for submit@debbugs.gnu.org; Wed, 29 Dec 2021 15:59:53 -0500 Received: from mail-ed1-f48.google.com ([209.85.208.48]:37610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2f9I-0002Ib-1D for 52873-done@debbugs.gnu.org; Wed, 29 Dec 2021 15:02:12 -0500 Received: by mail-ed1-f48.google.com with SMTP id o6so90141004edc.4 for <52873-done@debbugs.gnu.org>; Wed, 29 Dec 2021 12:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=equalexperts-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iNQEtNIZ35kWFTOWMLdU3nf9zw44gL9dT4chntuC/JY=; b=u3QStNlFSZeoag6PIMUDk0W41jwRKTm8XNXGwHyOoSqRoLnPYJ7LQOxLRD4lnW6rsP 9MPgQZGYutAagGClJK84RxSfQRbkrprn+eO58rge+w/waE51sOSj0mcQA3QnY1JHV8P7 JfmGIGXC758RB38Wb1bn8ebfa1DsTHxlObW8EyS2zuGYXWl68+SLH3X7xajd7dn9QxtJ VXxtMV7KqoVlWFQyciEvoQd7G1oOY27LrHNFzto6/XCuZ+RNBk09751EQmjo4KcUaobm x/WGOUZIHBmZx1oGEOz0pNrUL9n94tzMqZzIr8tO6Y/xFsEPZqJk8nEpymp0l5c21DI8 eadw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iNQEtNIZ35kWFTOWMLdU3nf9zw44gL9dT4chntuC/JY=; b=i+PxJpMZ2vt7yWmqwWD0cVw2SIOZeNNgXsAeSnsunRk5onncNwGZIWKzwsIl8DipND 43k8Xj7X2/DYYWoaMuQ5L7zLxhAD4Rx9LkWZkU4i/QIDMs3F0Cn9HqiGLy+H8wLsm7XH TjBNp7D3w7OuEfh5VOnYSWohwwiZh6f6zlupYGSjRm/rGBgYL/6CX04M80YxLTJUXCQR 3SntsQndzB6ZGtJN3731XrebzcJxvxWrwR5s8fm3XFkTi4EyHX1i6KoLRO45yxZYqW9n Vhb5DmbYNYG2bNDvxLnEKzwuFrR8vZ+E3rDyHP+X/pUiQN7EZK9v0/zNaGxpMq9a3Ckt wBLA== X-Gm-Message-State: AOAM530uuNQI4iBgOG90F5QDRBruI48GSiB9hazS5ItLvcEk2jYGmx+h C+yVTnSUYWZbF3fT2E/2g8qUBB3HWV4Zm+e/ce/t1w== X-Google-Smtp-Source: ABdhPJwMBZtnaDN1kRCnBnYbLZqzDk5AIxJT59+2jADel2lg9MbqOXWHsNgPTQc3XHfbGI3pF2jLlXTlQE9/Jby4Csw= X-Received: by 2002:a17:907:d0b:: with SMTP id gn11mr21641943ejc.379.1640808125953; Wed, 29 Dec 2021 12:02:05 -0800 (PST) MIME-Version: 1.0 References: <20211229173131.560e0680@swedishchef> <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> In-Reply-To: <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> From: Martin Rixham Date: Wed, 29 Dec 2021 20:01:54 +0000 Message-ID: Content-Type: multipart/alternative; boundary="0000000000007e14c005d44e6922" X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Wed, 29 Dec 2021 15:59:51 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000007e14c005d44e6922 Content-Type: text/plain; charset="UTF-8" What nonsense. I want to parse source code. ')' is not an uncommon line of source code. It should work. On Wed, 29 Dec 2021 at 19:52, Paul Eggert wrote: > On 12/29/21 08:31, Davide Brini wrote: > > I think you need to use '+' before the offending token > > Yes. That's a GNU extension. If you want to be portable to any POSIX > implementation, you can use this instead: > > expr "X(" : '.*' - 1 > > A similar example is given in the POSIX spec for 'expr': > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/expr.html > > As this is not a bug, I'm closing the bug report. > --0000000000007e14c005d44e6922 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
What nonsense. I want to parse source code. ')' is= not an uncommon line of source code. It should work.

On Wed, 29 Dec 2021 = at 19:52, Paul Eggert <eggert@cs.u= cla.edu> wrote:
On 12/29/21 08:31, Davide Brini wrote:
> I think you need to use '+' before the offending token

Yes. That's a GNU extension. If you want to be portable to any POSIX implementation, you can use this instead:

expr "X(" : '.*' - 1

A similar example is given in the POSIX spec for 'expr':

https://pubs.opengroup.org/onlin= epubs/9699919799/utilities/expr.html

As this is not a bug, I'm closing the bug report.
--0000000000007e14c005d44e6922-- From unknown Sat Aug 09 19:20:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#52873: expr unexpected syntax error Resent-From: Martin Rixham Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 29 Dec 2021 22:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52873 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: notabug To: Paul Eggert Cc: 52873-done@debbugs.gnu.org, Davide Brini Received: via spool by 52873-done@debbugs.gnu.org id=D52873.164081607325689 (code D ref 52873); Wed, 29 Dec 2021 22:15:02 +0000 Received: (at 52873-done) by debbugs.gnu.org; 29 Dec 2021 22:14:33 +0000 Received: from localhost ([127.0.0.1]:50567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2hDM-0006gG-BU for submit@debbugs.gnu.org; Wed, 29 Dec 2021 17:14:32 -0500 Received: from mail-ed1-f41.google.com ([209.85.208.41]:34458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n2h6k-0006TJ-Fs for 52873-done@debbugs.gnu.org; Wed, 29 Dec 2021 17:07:44 -0500 Received: by mail-ed1-f41.google.com with SMTP id x15so91151773edv.1 for <52873-done@debbugs.gnu.org>; Wed, 29 Dec 2021 14:07:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=equalexperts-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AlCMoOfgw1hMDDjh+P3A43mX5VBfsbnERK8pfrs8FgM=; b=DM3sO0scbHu0ii+EzcdRHFcFAwSNETR8gzxhJfU1kxCfQxinbglKMGWLvNS76+SB+X OLA2L8sI/JiyltbBUzSq0mh3SBVvO1LYF8vnvFUPN5bo+765arce8PvMBXUIo5JYHk4V 6oPiyDrE4XzYKsNKgnOeDByzMC0Q3mgYJYTWbKhPW0WAttHLxNcVBK8UCS4hLb8cyYQN FQXo4ugkxSdtq+eSdPdvJwstjcRBtqhSKisoE2AoRG3aSNuzNktoxf065ilBTNr6haSQ Og35m+NCePAsVh7Kpb49a0wMa5ijTftnbGncOnU6c2T2+09ormhJcpX1890x/nqpBiwY 7VCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AlCMoOfgw1hMDDjh+P3A43mX5VBfsbnERK8pfrs8FgM=; b=mIB3cL9TaU1oVlTQGFjTbwXil2gUFK8ZlVLMovIOnHNu1W/hlc+sEDXVKtZnZzKy2/ 0dENSJD3hhOF/l7c8WVuyXo/LlRrYqavisKwBgHCAa70Rl7bCg+avqnOKNopkmuVKgwn Ivs9Fr5cZS7fP9EJHmzJklWBnaPlP1pAW3Fpyb+WSJgn62vjWFGi3R2Ljs+JbNcmB32j y+210RVqBgPZ4Pwj8EcF09EKK15jKKfQtabyBr/GUEJQPG+3uZl0zmaQ/qpKf1Gxedca ybLRrrn3YGh6Kb/t/zqY6KgeIQXbLSOssZJVlmhzlX6OcvTXAeroXzt/OfcTRFrgQnVG NfVA== X-Gm-Message-State: AOAM531vykExI7ESR+zSniKBKyLRC75HdJ3xZ0zKXaHQUpab3riPHQn5 7vRHCtZNVCyaNwsdjz3/FF0hlhOtr2PmCi/9RD5nqg== X-Google-Smtp-Source: ABdhPJxVflg8xutvj7zIsaFdQIwkwXyfgXMs7IOXYsfMmuxmCfa+8nebemr36dzjZ2kNxROTxoeK2GsSGWK1p1mKvhc= X-Received: by 2002:aa7:cd45:: with SMTP id v5mr28442690edw.163.1640815656689; Wed, 29 Dec 2021 14:07:36 -0800 (PST) MIME-Version: 1.0 References: <20211229173131.560e0680@swedishchef> <3df84a2c-05aa-7aea-6d38-6ebe80a3b76f@cs.ucla.edu> In-Reply-To: From: Martin Rixham Date: Wed, 29 Dec 2021 22:07:25 +0000 Message-ID: Content-Type: multipart/alternative; boundary="0000000000005bf17c05d4502ab3" X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Wed, 29 Dec 2021 17:14:31 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --0000000000005bf17c05d4502ab3 Content-Type: text/plain; charset="UTF-8" ok I appreciate the explanation. On Wed, 29 Dec 2021 at 20:58, Paul Eggert wrote: > On 12/29/21 12:01, Martin Rixham wrote: > > What nonsense. I want to parse source code. ')' is not an uncommon line > of > > source code. It should work. > > Unfortunately, you're asking for what is in general impossible. If the > left argument of ':' could be any string, then the grammar for 'expr' > would be ambiguous. Consider the following shell command: > > expr '(' : ')' > > This outputs ':' because it evaluates the parenthesized string ':'; but > if the operands of ':' could be any strings it could also be interpreted > as matching '(' against ')', which means it should output the same thing > as 'expr a : b', namely '0'. > > Of course this means 'expr' was poorly designed in the 1970s, but we're > stuck with that design now (it's standardized by POSIX), portable code > must deal with this poor design, and for compatibility reasons it's > better for GNU expr to support the design, poor as it is. > > These days there are much better ways than 'expr' to parse code. For > example, if you want to count the number of characters in a shell > variable v, you can use this shell command: > > nv=${#v} > > This works even if v=')', whereas this: > > nv=$(expr "$v" : '.*') > > has the bug that you mentioned, plus it's harder to read and it's less > efficient. > --0000000000005bf17c05d4502ab3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
ok I appreciate the explanation.

On Wed, 29 Dec 2021 = at 20:58, Paul Eggert <eggert@cs.u= cla.edu> wrote:
On 12/29/21 12:01, Martin Rixham wrote:
> What nonsense. I want to parse source code. ')' is not an unco= mmon line of
> source code. It should work.

Unfortunately, you're asking for what is in general impossible. If the =
left argument of ':' could be any string, then the grammar for '= ;expr'
would be ambiguous. Consider the following shell command:

expr '(' : ')'

This outputs ':' because it evaluates the parenthesized string '= ;:'; but
if the operands of ':' could be any strings it could also be interp= reted
as matching '(' against ')', which means it should output t= he same thing
as 'expr a : b', namely '0'.

Of course this means 'expr' was poorly designed in the 1970s, but w= e're
stuck with that design now (it's standardized by POSIX), portable code =
must deal with this poor design, and for compatibility reasons it's better for GNU expr to support the design, poor as it is.

These days there are much better ways than 'expr' to parse code. Fo= r
example, if you want to count the number of characters in a shell
variable v, you can use this shell command:

nv=3D${#v}

This works even if v=3D')', whereas this:

nv=3D$(expr "$v" : '.*')

has the bug that you mentioned, plus it's harder to read and it's l= ess
efficient.
--0000000000005bf17c05d4502ab3--