From unknown Fri Aug 15 12:48:32 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#30919 <30919@debbugs.gnu.org> To: bug#30919 <30919@debbugs.gnu.org> Subject: Status: [grep: input file =?UTF-8?Q?'./x=E2=80=99?= is also the output] too late!.. have a null file. Reply-To: bug#30919 <30919@debbugs.gnu.org> Date: Fri, 15 Aug 2025 19:48:32 +0000 retitle 30919 [grep: input file './x=E2=80=99 is also the output] too late!= .. have a null file. reassign 30919 grep submitter 30919 openforum@davidpbrown.co.uk severity 30919 normal tag 30919 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 23 15:36:27 2018 Received: (at submit) by debbugs.gnu.org; 23 Mar 2018 19:36:27 +0000 Received: from localhost ([127.0.0.1]:50039 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezSUF-0003y1-1s for submit@debbugs.gnu.org; Fri, 23 Mar 2018 15:36:27 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezSUC-0003xn-74 for submit@debbugs.gnu.org; Fri, 23 Mar 2018 15:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ezSU5-0000rT-QD for submit@debbugs.gnu.org; Fri, 23 Mar 2018 15:36:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ezSU5-0000rB-My for submit@debbugs.gnu.org; Fri, 23 Mar 2018 15:36:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ezSU4-0005Nb-OR for bug-grep@gnu.org; Fri, 23 Mar 2018 15:36:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ezSU1-0000k8-Je for bug-grep@gnu.org; Fri, 23 Mar 2018 15:36:16 -0400 Received: from solstice.linksky124.com ([184.173.222.93]:55936) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ezSU1-00082J-EG for bug-grep@gnu.org; Fri, 23 Mar 2018 15:36:13 -0400 Received: from [134.19.180.169] (port=33674 helo=[10.7.7.22]) by solstice.linksky124.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1ezSTK-002wcn-RP for bug-grep@gnu.org; Fri, 23 Mar 2018 15:35:31 -0400 To: bug-grep@gnu.org From: davidpbrown Subject: =?UTF-8?Q?[grep:_input_file_'./x=e2=80=99_is_also_the_output]_too_l?= =?UTF-8?Q?ate!.._have_a_null_file.?= Message-ID: Date: Fri, 23 Mar 2018 19:35:26 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-LinkSkyHosting-MailScanner-Information: Please contact the ISP for more information X-LinkSkyHosting-MailScanner-ID: 1ezSTK-002wcn-RP X-LinkSkyHosting-MailScanner: Found to be clean X-LinkSkyHosting-MailScanner-SpamCheck: X-LinkSkyHosting-MailScanner-From: openforum@davidpbrown.co.uk X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - solstice.linksky124.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - davidpbrown.co.uk X-Get-Message-Sender-Via: solstice.linksky124.com: authenticated_id: bartender@davidpbrown.co.uk X-Authenticated-Sender: solstice.linksky124.com: bartender@davidpbrown.co.uk X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) 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: , Reply-To: openforum@davidpbrown.co.uk Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hi, Surprised that the error is noted but only after the file gets clobbered. Example: ===================== echo "blah" > ./x grep -v 'foo' ./x > ./x # grep: input file './x’ is also the output # results with x being empty. ===================== Would have expected that catch to be caught ahead of writing a null in place of the original file. bash -v suggests RELEASE: 2.1 this on Linux Mint. Regards davidpbrown From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 23 16:22:00 2018 Received: (at control) by debbugs.gnu.org; 23 Mar 2018 20:22:00 +0000 Received: from localhost ([127.0.0.1]:50072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezTCJ-0005NK-Vg for submit@debbugs.gnu.org; Fri, 23 Mar 2018 16:22:00 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54640 helo=mx1.redhat.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ezTCH-0005Mz-A0; Fri, 23 Mar 2018 16:21:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6C57EBFF0; Fri, 23 Mar 2018 20:21:51 +0000 (UTC) Received: from [10.10.121.135] (ovpn-121-135.rdu2.redhat.com [10.10.121.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5827984445; Fri, 23 Mar 2018 20:21:51 +0000 (UTC) Subject: =?UTF-8?Q?Re:_bug#30919:_[grep:_input_file_'./x=e2=80=99_is_also_th?= =?UTF-8?Q?e_output]_too_late!.._have_a_null_file.?= To: openforum@davidpbrown.co.uk, 30919-done@debbugs.gnu.org References: From: Eric Blake Organization: Red Hat, Inc. Message-ID: Date: Fri, 23 Mar 2018 15:21:50 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Mar 2018 20:21:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 23 Mar 2018 20:21:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eblake@redhat.com' RCPT:'' X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control 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: -2.3 (--) tag 30919 notabug thanks On 03/23/2018 02:35 PM, davidpbrown wrote: > Hi, > > Surprised that the error is noted but only after the file gets clobbered. > > Example: > ===================== > echo "blah" > ./x > grep -v 'foo' ./x > ./x Unfortunately, there is nothing grep can do about this. The file was already clobbered by your shell long before the shell even called exec() to start grep. I'm marking this as not a bug in grep's database, because there is nothing grep can do about it. I'm sorry for your data loss, but this is a naive beginner's mistake that multiple people have made for multiple years. The error message used in grep is reminiscent of the one used by 'sort --o'; at least there, sort really does have a chance to warn you before clobbering anything. But since 'grep -o' already means something different than 'sort -o', I'm not sure if it is worth introducing a new command line option, just so that: grep -v foo --new-option-for-output=./x ./x could properly warn (because in that style, it is grep, rather than the shell, that would be opening stdout, and thus could avoid the truncation). But even if we add a new option, it would take years before it reaches common distros, and would still be a GNU extension not present on other platforms, so you couldn't necessarily rely on it. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org From unknown Fri Aug 15 12:48:32 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 21 Apr 2018 11:24:04 +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