Gentoo Archives: gentoo-user

From: "Mariusz Pękala" <skoot@××.pl>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] [OT] confusing RE doesn't work in diff
Date: Thu, 28 Jul 2005 08:04:51
Message-Id: 20050728075936.GA15273@lisa.tutaj
In Reply to: Re: [gentoo-user] [OT] confusing RE doesn't work in diff by Christoph Gysin
1 On 2005-07-27 09:43:25 +0200 (Wed, Jul), Christoph Gysin wrote:
2 > Zhang Weiwu wrote:
3 > >zhangweiwu@Bach:/tmp$ diff -I "^[[:space:]]*/[*].*[*]/[[:space:]]*$"
4 > >header.inc.php empty
5 > >1,2d0
6 > >< <?php
7 > >< /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch
8 > >Exp $ */
9 > >
10 > >in man it's being said,
11 > > -I RE --ignore-matching-lines=RE
12 > > Ignore changes whose lines all match RE.
13 > >
14 > >I read man grep and it seems there are two sets of RE, extended and basic.
15 > >But it's not mensioned in diff(1) wheather or not diff(1) takes extended
16 > >or basic RE. I am using Debian so it should be gnu diff.
17 >
18 > If it's not mentioned, it possibly uses basic regular expressions.
19 >
20 > try:
21 >
22 > $ diff -I '/\* \$Id.*\$ \*/' header.inc.php empty
23 >
24 > Christoph
25
26 Indeed strange. BUT the clue lies in (after many strange results) in
27 'man grep' where, on my host, it says exactly:
28
29 -I regexp
30 Ignore changes that just insert or delete lines that match regexp.
31
32 Notice the word: 'changes'.
33 It seems that it means: ignore if WHOLE GROUP of DELETED OR INSERTED
34 lines matches (every added or deleted line) the provided regexp.
35
36 In your case the first line of header.inc.php is included in change-group
37 but does not matches RE.
38
39 Try (to be very simple):
40 $ diff -I '^.*/.*$' header empty
41 1,2d0
42 < <?php
43 < /* $Id: header.inc.php.template,v 1.58 2005/07/08 05:00:14 milosch Exp $ */
44
45 $ echo '<?php' > empty
46 $ diff -I '^.*/.*$' header empty
47 (nothing)
48 $ :>empty
49 $ diff -I '^.*php.*$' header empty
50 (nothing - because BOTH lines, considered CHANGED OR DELETED have the
51 word 'php' inside)
52
53 Now the difficult part: how to solve the real problem. :-)
54
55 * You may compare grepped files (with grepped out /* $Id:$ */)
56 * You may try to filter diff output... but I don't like this (by
57 intuition - I may be wrong)
58 * experiment with various options of diff. If only output (not retcode)
59 matters then good candidate maybe may be --changed-group-format, which is
60 weel described in 'info diff'
61 * or something other...
62
63 HTH
64
65 --
66 No virus found in this outgoing message.
67 Checked by 'grep -i virus $MESSAGE'
68 Trust me.