* [gentoo-user] [OT] confusing RE doesn't work in diff
@ 2005-07-25 9:50 Zhang Weiwu
2005-07-25 10:03 ` Christoph Gysin
2005-07-26 12:04 ` Mariusz Pękala
0 siblings, 2 replies; 6+ messages in thread
From: Zhang Weiwu @ 2005-07-25 9:50 UTC (permalink / raw
To: gentoo-user
My RE must be wrong but I can hardly successfully match a whole line
like the below example:
This works:
zhangweiwu@Bach:/tmp$ egrep "\b*\/[*].*[*]\/\b*" Calendar.php
/* $Id: class.boalarm.inc.php,v 1.1.1.1 2005/03/18 09:17:36
dawnlinux Exp $ */
/* $Id: class.boalarm.inc.php,v 1.11 2004/05/23 14:51:27
ralfbecker Exp $ */
This doesn't work:
zhangweiwu@Bach:/tmp$ egrep "^\b*\/[*].*[*]\/\b*$" Calendar.php
any hint?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] confusing RE doesn't work in diff
2005-07-25 9:50 Zhang Weiwu
@ 2005-07-25 10:03 ` Christoph Gysin
2005-07-26 12:04 ` Mariusz Pękala
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Gysin @ 2005-07-25 10:03 UTC (permalink / raw
To: gentoo-user
Zhang Weiwu wrote:
> This works:
> zhangweiwu@Bach:/tmp$ egrep "\b*\/[*].*[*]\/\b*" Calendar.php
> /* $Id: class.boalarm.inc.php,v 1.1.1.1 2005/03/18 09:17:36
> dawnlinux Exp $ */
> /* $Id: class.boalarm.inc.php,v 1.11 2004/05/23 14:51:27
> ralfbecker Exp $ */
>
> This doesn't work:
> zhangweiwu@Bach:/tmp$ egrep "^\b*\/[*].*[*]\/\b*$" Calendar.php
>
> any hint?
^ only matches at the beginning of a line. This isn't the case in your
examples.
Christoph
--
echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] confusing RE doesn't work in diff
2005-07-25 9:50 Zhang Weiwu
2005-07-25 10:03 ` Christoph Gysin
@ 2005-07-26 12:04 ` Mariusz Pękala
1 sibling, 0 replies; 6+ messages in thread
From: Mariusz Pękala @ 2005-07-26 12:04 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
On 2005-07-25 17:50:37 +0800 (Mon, Jul), Zhang Weiwu wrote:
> My RE must be wrong but I can hardly successfully match a whole line
> like the below example:
>
> This works:
> zhangweiwu@Bach:/tmp$ egrep "\b*\/[*].*[*]\/\b*" Calendar.php
> /* $Id: class.boalarm.inc.php,v 1.1.1.1 2005/03/18 09:17:36
> dawnlinux Exp $ */
> /* $Id: class.boalarm.inc.php,v 1.11 2004/05/23 14:51:27
> ralfbecker Exp $ */
>
> This doesn't work:
> zhangweiwu@Bach:/tmp$ egrep "^\b*\/[*].*[*]\/\b*$" Calendar.php
>
> any hint?
man grep:
The symbol \b matches the empty string at the edge of a word
It seems that '/' is not considered to be a part of a word.
I suppose you may use "^[[:space:]]*/[*].*[*]/[[:space:]]*$" Calendar.php
--
No virus found in this outgoing message.
Checked by 'grep -i virus $MESSAGE'
Trust me.
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] confusing RE doesn't work in diff
@ 2005-07-27 7:08 Zhang Weiwu
2005-07-27 7:43 ` Christoph Gysin
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Weiwu @ 2005-07-27 7:08 UTC (permalink / raw
To: gentoo-user; +Cc: skoot
Mariusz Pękala wrote:
> On 2005-07-25 17:50:37 +0800 (Mon, Jul), Zhang Weiwu wrote:
> > > My RE must be wrong but I can hardly successfully match a whole line
> > > like the below example:
> > >
> > > This works:
> > > zhangweiwu@Bach:/tmp$ egrep "\b*\/[*].*[*]\/\b*" Calendar.php
> > > /* $Id: class.boalarm.inc.php,v 1.1.1.1 2005/03/18 09:17:36
> > > dawnlinux Exp $ */
> > > /* $Id: class.boalarm.inc.php,v 1.11 2004/05/23 14:51:27
> > > ralfbecker Exp $ */
> > >
> > > This doesn't work:
> > > zhangweiwu@Bach:/tmp$ egrep "^\b*\/[*].*[*]\/\b*$" Calendar.php
> > >
> > > any hint?
>
> man grep:
> The symbol \b matches the empty string at the edge of a word
>
> It seems that '/' is not considered to be a part of a word.
>
> I suppose you may use "^[[:space:]]*/[*].*[*]/[[:space:]]*$" Calendar.php
Thank you! Your RE suggested does work and I discovered this [[:space:]] pretty useful. I missed it in man grep.
However there is another strange behavor. This works:
zhangweiwu@Bach:/tmp$ cat header.inc.php
<?php
/* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
zhangweiwu@Bach:/tmp$ grep "^[[:space:]]*/[*].*[*]/[[:space:]]*$" header.inc.php
/* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
And this doesn't work:
zhangweiwu@Bach:/tmp$ :>empty
zhangweiwu@Bach:/tmp$ diff -I "^[[:space:]]*/[*].*[*]/[[:space:]]*$" header.inc.php empty
1,2d0
< <?php
< /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
in man it's being said,
-I RE --ignore-matching-lines=RE
Ignore changes whose lines all match RE.
I read man grep and it seems there are two sets of RE, extended and basic. But it's not mensioned in diff(1) wheather or not diff(1) takes extended or basic RE. I am using Debian so it should be gnu diff.
Any thing more to teach me?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] confusing RE doesn't work in diff
2005-07-27 7:08 [gentoo-user] [OT] confusing RE doesn't work in diff Zhang Weiwu
@ 2005-07-27 7:43 ` Christoph Gysin
2005-07-28 7:59 ` Mariusz Pękala
0 siblings, 1 reply; 6+ messages in thread
From: Christoph Gysin @ 2005-07-27 7:43 UTC (permalink / raw
To: gentoo-user
Zhang Weiwu wrote:
> zhangweiwu@Bach:/tmp$ diff -I "^[[:space:]]*/[*].*[*]/[[:space:]]*$" header.inc.php empty
> 1,2d0
> < <?php
> < /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
>
> in man it's being said,
> -I RE --ignore-matching-lines=RE
> Ignore changes whose lines all match RE.
>
> I read man grep and it seems there are two sets of RE, extended and basic. But it's not mensioned in diff(1) wheather or not diff(1) takes extended or basic RE. I am using Debian so it should be gnu diff.
If it's not mentioned, it possibly uses basic regular expressions.
try:
$ diff -I '/\* \$Id.*\$ \*/' header.inc.php empty
Christoph
--
echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] [OT] confusing RE doesn't work in diff
2005-07-27 7:43 ` Christoph Gysin
@ 2005-07-28 7:59 ` Mariusz Pękala
0 siblings, 0 replies; 6+ messages in thread
From: Mariusz Pękala @ 2005-07-28 7:59 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 2208 bytes --]
On 2005-07-27 09:43:25 +0200 (Wed, Jul), Christoph Gysin wrote:
> Zhang Weiwu wrote:
> >zhangweiwu@Bach:/tmp$ diff -I "^[[:space:]]*/[*].*[*]/[[:space:]]*$"
> >header.inc.php empty
> >1,2d0
> >< <?php
> >< /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch
> >Exp $ */
> >
> >in man it's being said,
> > -I RE --ignore-matching-lines=RE
> > Ignore changes whose lines all match RE.
> >
> >I read man grep and it seems there are two sets of RE, extended and basic.
> >But it's not mensioned in diff(1) wheather or not diff(1) takes extended
> >or basic RE. I am using Debian so it should be gnu diff.
>
> If it's not mentioned, it possibly uses basic regular expressions.
>
> try:
>
> $ diff -I '/\* \$Id.*\$ \*/' header.inc.php empty
>
> Christoph
Indeed strange. BUT the clue lies in (after many strange results) in
'man grep' where, on my host, it says exactly:
-I regexp
Ignore changes that just insert or delete lines that match regexp.
Notice the word: 'changes'.
It seems that it means: ignore if WHOLE GROUP of DELETED OR INSERTED
lines matches (every added or deleted line) the provided regexp.
In your case the first line of header.inc.php is included in change-group
but does not matches RE.
Try (to be very simple):
$ diff -I '^.*/.*$' header empty
1,2d0
< <?php
< /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
$ echo '<?php' > empty
$ diff -I '^.*/.*$' header empty
(nothing)
$ :>empty
$ diff -I '^.*php.*$' header empty
(nothing - because BOTH lines, considered CHANGED OR DELETED have the
word 'php' inside)
Now the difficult part: how to solve the real problem. :-)
* You may compare grepped files (with grepped out /* $Id:$ */)
* You may try to filter diff output... but I don't like this (by
intuition - I may be wrong)
* experiment with various options of diff. If only output (not retcode)
matters then good candidate maybe may be --changed-group-format, which is
weel described in 'info diff'
* or something other...
HTH
--
No virus found in this outgoing message.
Checked by 'grep -i virus $MESSAGE'
Trust me.
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-07-28 8:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-27 7:08 [gentoo-user] [OT] confusing RE doesn't work in diff Zhang Weiwu
2005-07-27 7:43 ` Christoph Gysin
2005-07-28 7:59 ` Mariusz Pękala
-- strict thread matches above, loose matches on Subject: below --
2005-07-25 9:50 Zhang Weiwu
2005-07-25 10:03 ` Christoph Gysin
2005-07-26 12:04 ` Mariusz Pękala
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox