Subject: bug#5812 closed by Bob Proulx <[email-masked]> (Re: bug#5812: expr: Difference in behavior of match and :)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 05 Apr 2010 04:43:02 +0000

This is an automatic notification regarding your bug report
which was filed against the coreutils package:

#5812: expr: Difference in behavior of match and :

It has been closed by Bob Proulx <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Bob Proulx <[email-masked]> by
replying to this email.

-- 
5812: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5812
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#5812: expr: Difference in behavior of match and :
From: Bob Proulx <[email-masked]>
To: Adil Mujeeb <[email-masked]>
Cc: [email-masked]
Date: Sun, 4 Apr 2010 22:42:13 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

Adil Mujeeb wrote:
> Thanks Bob for such a nice explanation and your instinct is right. It is
> locale problem.
> ...
> And the other point you made is also right. I didn’t realize that I was
> using another session for comparing the result with match which ahs
> different locale:-

I thought it might have been something like that.

> I never knew that locale has effect on the behavior. We can close this bug.

I will close the bug with this message then.

> Thank you so much for your time and details, I have learnt new thing :)

I am glad to have helped!

> Also, thanks for correcting my regex.

Sure thing!

Bob

Subject: expr: Difference in behavior of match and :
From: Adil Mujeeb <[email-masked]>
To: [email-masked]
Date: Wed, 31 Mar 2010 18:35:16 +0530
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello team,

I have tried following snippet in a bash script:

-bash-3.1$userid=`expr "uid=11008(ADILM) gid=1200(cvs),1400(build)" :
".*uid=[0-9]*(\(.[0-9a-z]*\)) .*"`
-bash-3.1$echo $userid
ADILM
-bash-3.1$

To my knowledge it should not able to extract ADILM as the regex does not
include uppercase letters (A-Z).

In the expr man page it is mentioned that:

-----8<----------
match STRING REGEXP
 same as STRING : REGEXP
-----8<----------

So i tried following snippet:-

-bash-3.1$ userid=`expr match "uid=11008(ADILM) gid=1200(cvs),1400(build)"
".*uid=[0-9]*(\(.[0-9a-z]*\)) .*"`
-bash-3.1$ echo $userid

-bash-3.1$

I changed the regex and added uppercase letters:-
-bash-3.1$ userid=`expr match "uid=11008(ADILM) gid=1200(cvs),1400(build)"
".*uid=[0-9]*(\(.[0-9A-Za-z]*\)) .*"`
-bash-3.1$ echo $userid
ADILM
-bash-3.1$

So it means that match is not same as ":". As per observation ":" uses
case-insensitive matching while match is strict case sensitive matching.

Can you update the man page OR let me know if i am doing anything wrong?

Package:-
-bash-3.1$ rpm -qf /usr/bin/expr
coreutils-5.97-12.1.el5
-bash-3.1$

Thanks and Regards,
Adil Mujeeb