emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55652: closed (please elaborate on diff -u -I RE)


From: GNU bug Tracking System
Subject: bug#55652: closed (please elaborate on diff -u -I RE)
Date: Fri, 27 May 2022 01:54:02 +0000

Your message dated Thu, 26 May 2022 18:53:20 -0700
with message-id <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu>
and subject line Re: [bug-diffutils] bug#55652: please elaborate on diff -u -I 
RE
has caused the debbugs.gnu.org bug report #55652,
regarding please elaborate on diff -u -I RE
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
55652: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55652
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: please elaborate on diff -u -I RE Date: Thu, 26 May 2022 11:15:39 +0200 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1
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



--- End Message ---
--- Begin Message --- Subject: Re: [bug-diffutils] bug#55652: please elaborate on diff -u -I RE Date: Thu, 26 May 2022 18:53:20 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0
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".


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]