bug#52873: expr unexpected syntax error

2021-12-29 Thread Paul Eggert
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

bug#52873: expr unexpected syntax error

2021-12-29 Thread Martin Rixham
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

bug#52873: expr unexpected syntax error

2021-12-29 Thread Martin Rixham
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

bug#52873: expr unexpected syntax error

2021-12-29 Thread Martin Rixham
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)

bug#52873: expr unexpected syntax error

2021-12-29 Thread Davide Brini
On Wed, 29 Dec 2021 12:42:24 +, 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

bug#52873: expr unexpected syntax error

2021-12-29 Thread Paul Eggert
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':