From unknown Tue Jun 17 20:12:35 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#55652 <55652@debbugs.gnu.org> To: bug#55652 <55652@debbugs.gnu.org> Subject: Status: please elaborate on diff -u -I RE Reply-To: bug#55652 <55652@debbugs.gnu.org> Date: Wed, 18 Jun 2025 03:12:35 +0000 retitle 55652 please elaborate on diff -u -I RE reassign 55652 diffutils submitter 55652 Harald Dunkel severity 55652 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu May 26 05:15:58 2022 Received: (at submit) by debbugs.gnu.org; 26 May 2022 09:15:58 +0000 Received: from localhost ([127.0.0.1]:57061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nu9b4-0005l5-2v for submit@debbugs.gnu.org; Thu, 26 May 2022 05:15:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:59040) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nu9b2-0005ky-NA for submit@debbugs.gnu.org; Thu, 26 May 2022 05:15:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nu9b2-0006uE-Ee for bug-diffutils@gnu.org; Thu, 26 May 2022 05:15:56 -0400 Received: from mordac.selfhost.de ([82.98.82.6]:55247 helo=outgoing.selfhost.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nu9b0-0000gN-FW for bug-diffutils@gnu.org; Thu, 26 May 2022 05:15:56 -0400 Received: (qmail 5098 invoked from network); 26 May 2022 09:15:39 -0000 Received: from unknown (HELO mailhost.afaics.de) (postmaster@xqrsonfo.mail.selfhost.de@87.160.253.127) by mailout.selfhost.de with ESMTPA; 26 May 2022 09:15:39 -0000 Received: from [10.42.100.14] (cecil.afaics.de [10.42.100.14]) by marvin.afaics.de (OpenSMTPD) with ESMTP id 41afc141; Thu, 26 May 2022 11:15:39 +0200 (CEST) Message-ID: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de> Date: Thu, 26 May 2022 11:15:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 To: bug-diffutils@gnu.org Content-Language: en-US From: Harald Dunkel Subject: please elaborate on diff -u -I RE Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=82.98.82.6; envelope-from=harri@afaics.de; helo=outgoing.selfhost.de X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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 From debbugs-submit-bounces@debbugs.gnu.org Thu May 26 21:53:30 2022 Received: (at 55652-done) by debbugs.gnu.org; 27 May 2022 01:53:31 +0000 Received: from localhost ([127.0.0.1]:60383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuPAQ-0004kl-Mx for submit@debbugs.gnu.org; Thu, 26 May 2022 21:53:30 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:45172) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuPAO-0004kU-GR for 55652-done@debbugs.gnu.org; Thu, 26 May 2022 21:53:29 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AEE8F160137; Thu, 26 May 2022 18:53:21 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id oKohj5PLSSip; Thu, 26 May 2022 18:53:21 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 06766160139; Thu, 26 May 2022 18:53:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pDdFxZ8Zdtf1; Thu, 26 May 2022 18:53:20 -0700 (PDT) Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id D81A8160137; Thu, 26 May 2022 18:53:20 -0700 (PDT) Message-ID: <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu> Date: Thu, 26 May 2022 18:53:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [bug-diffutils] bug#55652: please elaborate on diff -u -I RE Content-Language: en-US To: Harald Dunkel References: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 55652-done Cc: 55652-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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". From debbugs-submit-bounces@debbugs.gnu.org Fri May 27 03:54:06 2022 Received: (at 55652-done) by debbugs.gnu.org; 27 May 2022 07:54:06 +0000 Received: from localhost ([127.0.0.1]:60834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuUnH-00080t-1m for submit@debbugs.gnu.org; Fri, 27 May 2022 03:54:06 -0400 Received: from mordac.selfhost.de ([82.98.82.6]:38037 helo=outgoing.selfhost.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuUnF-00080k-4W for 55652-done@debbugs.gnu.org; Fri, 27 May 2022 03:53:57 -0400 Received: (qmail 10322 invoked from network); 27 May 2022 07:53:55 -0000 Received: from unknown (HELO mailhost.afaics.de) (postmaster@xqrsonfo.mail.selfhost.de@87.160.253.127) by mailout.selfhost.de with ESMTPA; 27 May 2022 07:53:55 -0000 Received: from [10.42.100.14] (cecil.afaics.de [10.42.100.14]) by marvin.afaics.de (OpenSMTPD) with ESMTP id ffe075ec; Fri, 27 May 2022 09:53:55 +0200 (CEST) Message-ID: Date: Fri, 27 May 2022 09:53:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Harald Dunkel Subject: Re: [bug-diffutils] bug#55652: please elaborate on diff -u -I RE To: Paul Eggert References: <1d037236-055e-ffa8-7624-ede9ea58b009@afaics.de> <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu> Content-Language: en-US In-Reply-To: <67d65b7a-1438-9033-e331-6791bc0043f8@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 55652-done Cc: 55652-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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 From unknown Tue Jun 17 20:12:35 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 24 Jun 2022 11:24:06 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator