Hi!
Currently 'expr' always tries to evaluate its arguments as numbers
even when the operation performed will require strings. This leads
to couple different bugs reported on [dev][0].
First: `expr 3 : '.*'` should evaluate to the length of the
string but currently it evaluates to 1.
Second:
Comparison operations (>, <, =, etc.) and matching operations must
operate originally provided string not one that has gone back and
forth through string formatting. This caused operations such as
the following to give incorrect results:
./expr 3 : '.*'
Before: 1
After: 5
This commit fixes th
POSIX specifies that if the pattern contains a subexpression then
the first matched subexpression should be returned if it exists.
This fixes things like the following:
./expr 3 : '\(.*\)'
Before: 3
After: 3
---
expr.c | 13 ++---
1 file changed, 2 insertions(+), 11 deletions(-)