GNU bug report logs -
#55652
please elaborate on diff -u -I RE
Previous Next
Reported by: Harald Dunkel <harri <at> afaics.de>
Date: Thu, 26 May 2022 09:16:02 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55652 in the body.
You can then email your comments to 55652 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-diffutils <at> gnu.org
:
bug#55652
; Package
diffutils
.
(Thu, 26 May 2022 09:16:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Harald Dunkel <harri <at> afaics.de>
:
New bug report received and forwarded. Copy sent to
bug-diffutils <at> gnu.org
.
(Thu, 26 May 2022 09:16:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi folks,
I have hoped that
diff -I '^[[:space:]]*\#' file1 file2
would ignore comment lines, but it doesn't work as I expected.
Example:
#!/bin/bash
diff -version | head -1
echo -e '\t# comment 1' >/tmp/x1
echo -e '\t# comment 2' >/tmp/x2
diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'
echo -e '' >>/tmp/x1
echo -e '' >>/tmp/x2
diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'still no diffs'
echo -e 'hello, world' >>/tmp/x2
diff -u -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'
echo "diff --normal"
diff -I '^[[:space:]]*\#' /tmp/x1 /tmp/x2 && echo 'no diffs'
Output:
diff (GNU diffutils) 3.8
no diffs
still no diffs
--- /tmp/x1 2022-05-26 10:54:36.187361365 +0200
+++ /tmp/x2 2022-05-26 10:54:36.191361276 +0200
@@ -1,2 +1,3 @@
- # comment 1
+ # comment 2
+hello, world
diff --normal
2a3
> hello, world
This seems weird. Only 1 line has been appended to x2 before running
diff the third time. It does not match the pattern. How comes diff -u
reports 2 different lines, with an unchanged line in between? Is this
as expected?
Regards
Harri
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Fri, 27 May 2022 01:54:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Harald Dunkel <harri <at> afaics.de>
:
bug acknowledged by developer.
(Fri, 27 May 2022 01:54:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 55652-done <at> debbugs.gnu.org (full text, mbox):
On 5/26/22 02:15, Harald Dunkel wrote:
> How comes diff -u
> reports 2 different lines, with an unchanged line in between?
What else can diff do? You asked for context, and the context lines differ.
> Is this
> as expected?
Yes, the manual says:
However, '-I' only ignores the insertion or deletion of lines that
contain the regular expression if every changed line in the hunk--every
insertion and every deletion--matches the regular expression. In other
words, for each nonignorable change, 'diff' prints the complete set of
changes in its vicinity, including the ignorable ones.
One might add an option to make diff behave differently in this case,
although it's not clear what the "right" behavior would be. In the
meantime perhaps you can get by with "diff -U0 -Iwhatever".
Information forwarded
to
bug-diffutils <at> gnu.org
:
bug#55652
; Package
diffutils
.
(Fri, 27 May 2022 07:55:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 55652-done <at> debbugs.gnu.org (full text, mbox):
Hi Paul,
On 2022-05-27 03:53:20, Paul Eggert wrote:
> On 5/26/22 02:15, Harald Dunkel wrote:
>> How comes diff -u
>> reports 2 different lines, with an unchanged line in between?
>
> What else can diff do? You asked for context, and the context lines differ.
>
It could show the old ignored lines as unchanged, of course. This would allow
to apply the diff using patch. If it would show the new ignored lines instead,
then you could only reverse apply the diff, which is much less likely to be
useful. In the current implementation it is not useful at all.
>
>> Is this
>> as expected?
>
> Yes, the manual says:
>
> However, '-I' only ignores the insertion or deletion of lines that
> contain the regular expression if every changed line in the hunk--every
> insertion and every deletion--matches the regular expression. In other
> words, for each nonignorable change, 'diff' prints the complete set of
> changes in its vicinity, including the ignorable ones.
>
Where did you find this? The man page for diffutils 3.8 doesn't tell.
Regards
Harri
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 24 Jun 2022 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 358 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.