Subject: Re: expr "foo" : '/'
To: Andrew Cagney <cagney@mac.com>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: current-users
Date: 02/06/2002 12:27:51
Andrew Cagney <cagney@mac.com> writes:

> This is one for the POSIX police.  Is:
> 
> 	$ expr "foo" : '/'
> 	expr: syntax error
> 
> correct? 

I think it's ambiguous; the : operator has higher precedence than the
/ operator, but it's unclear whether the '/' should be considered a
regexp for : or a lonely, invalid division operator.

Note that expr(1) has been thoroughly reimplemented (entirely in
yacc!) in -current, though, and the behaviour of that expression has
changed:

$ expr "foo" : '/'
0
$ expr "foo" : '\/'
0
$ expr //a : '.*/\(.*\)'
a

        - Nathan