From unknown Tue Aug 19 05:10:27 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#12339 <12339@debbugs.gnu.org> To: bug#12339 <12339@debbugs.gnu.org> Subject: Status: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Reply-To: bug#12339 <12339@debbugs.gnu.org> Date: Tue, 19 Aug 2025 12:10:27 +0000 retitle 12339 Bug: rm -fr . doesn't dir depth first deletion yet it is docu= mented to do so. reassign 12339 coreutils submitter 12339 Linda Walsh severity 12339 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 02 20:33:57 2012 Received: (at submit) by debbugs.gnu.org; 3 Sep 2012 00:33:57 +0000 Received: from localhost ([127.0.0.1]:35175 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Kc1-0003Gw-5Q for submit@debbugs.gnu.org; Sun, 02 Sep 2012 20:33:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55402) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Kbz-0003Gp-2L for submit@debbugs.gnu.org; Sun, 02 Sep 2012 20:33:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8KaW-00083f-T4 for submit@debbugs.gnu.org; Sun, 02 Sep 2012 20:32:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:55688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8KaW-00083b-Px for submit@debbugs.gnu.org; Sun, 02 Sep 2012 20:32:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8KaV-0001rt-Ti for bug-coreutils@gnu.org; Sun, 02 Sep 2012 20:32:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8KaU-00083P-Ro for bug-coreutils@gnu.org; Sun, 02 Sep 2012 20:32:23 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:53290 helo=Ishtar.sc.tlinx.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8KaU-00083H-HR for bug-coreutils@gnu.org; Sun, 02 Sep 2012 20:32:22 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q830WIlG037609 for ; Sun, 2 Sep 2012 17:32:20 -0700 Message-ID: <5043FA91.9070703@tlinx.org> Date: Sun, 02 Sep 2012 17:32:17 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: bug-coreutils@gnu.org Subject: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) I'm not sure what the rational for putting in special check to try to remove the current directory *before*, it's children is, but it's not correct behavior. It used to be it just 'ignored' an attempt to delete the current dir and deleted all the files under it. Now there seems to be a special check for "." and disallow it as a rm target. But that was a safe and portable way to delete all contents. can't use '*', -- it is expanded differently depending on shell and settings! I always felt a bit safer if I was able to cd into the dir I wanted, then rm -fr from the root of that dir by specifying '.' Could that be added back in as a safe and portable way to do rm *, where I don't have to worry about whether or not it applies the * will pick up hidden files. I would expect it to delete all but the current inode I'm parked on, and for it -- either issue an error or silently ignore ... preferring 'DoWIMean' versus 'technically'...as being more user friendly. Sides -- it normally does depth-first traversal --- since you can't delete a dir with contents still in it -- so why different for '.'? From debbugs-submit-bounces@debbugs.gnu.org Sun Sep 02 23:55:25 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 03:55:25 +0000 Received: from localhost ([127.0.0.1]:35311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Nkz-0007mc-G7 for submit@debbugs.gnu.org; Sun, 02 Sep 2012 23:55:25 -0400 Received: from joseki.proulx.com ([216.17.153.58]:36649) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Nkx-0007mV-I5 for 12339@debbugs.gnu.org; Sun, 02 Sep 2012 23:55:24 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 70597211D9; Sun, 2 Sep 2012 21:53:52 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 2CFFB2DCC2; Sun, 2 Sep 2012 21:53:52 -0600 (MDT) Date: Sun, 2 Sep 2012 21:53:52 -0600 From: Bob Proulx To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Message-ID: <20120903035351.GA5872@hysteria.proulx.com> References: <5043FA91.9070703@tlinx.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5043FA91.9070703@tlinx.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Linda Walsh wrote: > Now there seems to be a special check for "." and disallow it as a > rm target. But that was a safe and portable way to delete all contents. > ... > I would expect it to delete all but the current inode I'm parked on, and > for it -- either issue an error or silently ignore ... preferring 'DoWIMean' > versus 'technically'...as being more user friendly. > > Sides -- it normally does depth-first traversal --- since you can't delete > a dir with contents still in it -- so why different for '.'? +1. Feels like a bug to me. Workaround: find . -delete Bob From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 02:39:56 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 06:39:56 +0000 Received: from localhost ([127.0.0.1]:35470 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8QKB-00037g-8x for submit@debbugs.gnu.org; Mon, 03 Sep 2012 02:39:56 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:35369 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8QK8-00037Y-GK for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 02:39:53 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q836cIX4084068 for <12339@debbugs.gnu.org>; Sun, 2 Sep 2012 23:38:20 -0700 Message-ID: <5044505A.2020607@tlinx.org> Date: Sun, 02 Sep 2012 23:38:18 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: 12339@debbugs.gnu.org Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <20120903035351.GA5872@hysteria.proulx.com> In-Reply-To: <20120903035351.GA5872@hysteria.proulx.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Workaround: > > find . -delete > > Bob ---- not the first thing one one think of to rm a dir tree. I didn't even know find had a delete op... (use find alot, but 70% of the time it's to pipe into xargs...) From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 03:29:32 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 07:29:32 +0000 Received: from localhost ([127.0.0.1]:35520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8R6C-0004DW-45 for submit@debbugs.gnu.org; Mon, 03 Sep 2012 03:29:32 -0400 Received: from mx.meyering.net ([88.168.87.75]:34592) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8R68-0004DO-VS for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 03:29:30 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 90FFE60103; Mon, 3 Sep 2012 09:27:56 +0200 (CEST) From: Jim Meyering To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <5043FA91.9070703@tlinx.org> (Linda Walsh's message of "Sun, 02 Sep 2012 17:32:17 -0700") References: <5043FA91.9070703@tlinx.org> Date: Mon, 03 Sep 2012 09:27:56 +0200 Message-ID: <877gsbk1kz.fsf@rho.meyering.net> Lines: 47 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Linda Walsh wrote: > I'm not sure what the rational for putting in special check to > try to remove the current directory *before*, it's children is, > but it's not correct behavior. > > It used to be it just 'ignored' an attempt to delete the current dir > and deleted all the files under it. I see from your mention of "." below that you are objecting to rm's refusal to remove "." or "..". Could you be thinking of some other rm? Coreutils' rm has rejected that for a long time: $ rm -rf .; rm --version | head -1 rm: cannot remove `.' or `..' rm (GNU fileutils) 3.16 > Now there seems to be a special check for "." and disallow it as a > rm target. But that was a safe and portable way to delete all contents. > > can't use '*', -- it is expanded differently depending on shell and settings! > > I always felt a bit safer if I was able to cd into the dir I wanted, then > rm -fr from the root of that dir by specifying '.' POSIX requires rm to reject any attempt to delete an explicitly specified "." or ".." argument (or any argument whose last component is one of those): http://pubs.opengroup.org/onlinepubs/000095399/utilities/rm.html > Could that be added back in as a safe and portable way to do rm *, where I > don't have to worry about whether or not it applies the * will pick up > hidden files. I suggest you use Bob's suggestion: find . -delete > I would expect it to delete all but the current inode I'm parked on, and > for it -- either issue an error or silently ignore ... preferring 'DoWIMean' > versus 'technically'...as being more user friendly. > > Sides -- it normally does depth-first traversal --- since you can't delete > a dir with contents still in it -- so why different for '.'? Safety, I suspect. "." and ".." may not mean anything to a novice. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 03:52:08 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 07:52:08 +0000 Received: from localhost ([127.0.0.1]:35529 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8RS4-0004ix-53 for submit@debbugs.gnu.org; Mon, 03 Sep 2012 03:52:08 -0400 Received: from joseki.proulx.com ([216.17.153.58]:37448) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8RS1-0004in-CI for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 03:52:06 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 3B57221250; Mon, 3 Sep 2012 01:50:33 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id BDCBD2DCC2; Mon, 3 Sep 2012 01:50:32 -0600 (MDT) Date: Mon, 3 Sep 2012 01:50:32 -0600 From: Bob Proulx To: Linda Walsh , 12339@debbugs.gnu.org Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Message-ID: <20120903075032.GA29375@hysteria.proulx.com> References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877gsbk1kz.fsf@rho.meyering.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Jim Meyering wrote: > Could you be thinking of some other rm? > Coreutils' rm has rejected that for a long time: > ... > POSIX requires rm to reject any attempt to delete an explicitly specified > "." or ".." argument (or any argument whose last component is one of those): Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release from twelve years ago in 2000, the oldest easily available to me, and got this: $ /usr/bin/rm -rf . rm: cannot remove .. or . So I guess GNU coreutils is in good company with traditional Unix systems! It has definitely been that way for a long time. Bob From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 04:19:18 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 08:19:18 +0000 Received: from localhost ([127.0.0.1]:35559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8RsM-0005Ko-BD for submit@debbugs.gnu.org; Mon, 03 Sep 2012 04:19:18 -0400 Received: from c-67-162-91-36.hsd1.in.comcast.net ([67.162.91.36]:45709 helo=kosh.dhis.org) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T8RsL-0005Ki-1T for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 04:19:17 -0400 Received: (qmail 26919 invoked by uid 1000); 3 Sep 2012 08:17:44 -0000 Message-ID: <20120903081744.26918.qmail@kosh.dhis.org> From: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is To: bob@proulx.com (Bob Proulx) Date: Mon, 3 Sep 2012 03:17:44 -0500 (GMT+5) In-Reply-To: <20120903075032.GA29375@hysteria.proulx.com> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Bob Proulx writes: > > Jim Meyering wrote: > > Could you be thinking of some other rm? > > Coreutils' rm has rejected that for a long time: > > ... > > POSIX requires rm to reject any attempt to delete an explicitly specified > > "." or ".." argument (or any argument whose last component is one of those): > > Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release > from twelve years ago in 2000, the oldest easily available to me, and > got this: > > $ /usr/bin/rm -rf . > rm: cannot remove .. or . > > So I guess GNU coreutils is in good company with traditional Unix > systems! It has definitely been that way for a long time. [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Bob Proulx writes: > > Jim Meyering wrote: > > Could you be thinking of some other rm? > > Coreutils' rm has rejected that for a long time: > > ... > > POSIX requires rm to reject any attempt to delete an explicitly specified > > "." or ".." argument (or any argument whose last component is one of those): > > Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release > from twelve years ago in 2000, the oldest easily available to me, and > got this: > > $ /usr/bin/rm -rf . > rm: cannot remove .. or . > > So I guess GNU coreutils is in good company with traditional Unix > systems! It has definitely been that way for a long time. [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Bob Proulx writes: > > Jim Meyering wrote: > > Could you be thinking of some other rm? > > Coreutils' rm has rejected that for a long time: > > ... > > POSIX requires rm to reject any attempt to delete an explicitly specified > > "." or ".." argument (or any argument whose last component is one of those): > > Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release > from twelve years ago in 2000, the oldest easily available to me, and > got this: > > $ /usr/bin/rm -rf . > rm: cannot remove .. or . > > So I guess GNU coreutils is in good company with traditional Unix > systems! It has definitely been that way for a long time. Linux has the ability to actually remove a directory that is empty but still referenced as the cwd of some process. This ability is non-traditional (my fuzzy memory says it showed up some time in the 2.2 or 2.4 era). It's worth considering whether this change should be reflected by a relaxation of rm's traditional behavior. rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves you in a directory so empty that ls -a reports no "." or ".." entries, and no file can be created in the current directory. (open and stat and chdir still work on . and .. though. They're magic.) -- Alan Curry From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 04:26:31 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 08:26:31 +0000 Received: from localhost ([127.0.0.1]:35564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8RzJ-0005Ud-2f for submit@debbugs.gnu.org; Mon, 03 Sep 2012 04:26:31 -0400 Received: from senmx11-mx.siemens-enterprise.com ([62.134.46.9]:54958) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8RzG-0005UU-5V for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 04:26:27 -0400 Received: from MCHP02HTC.global-ad.net (unknown [172.29.42.235]) by senmx11-mx.siemens-enterprise.com (Server) with ESMTP id C46B91EB8405; Mon, 3 Sep 2012 10:24:53 +0200 (CEST) Received: from MCHP02MSX.global-ad.net ([169.254.4.126]) by MCHP02HTC.global-ad.net ([172.29.42.235]) with mapi id 14.02.0309.002; Mon, 3 Sep 2012 10:24:53 +0200 From: "Voelker, Bernhard" To: Bob Proulx , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> Subject: RE: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Thread-Topic: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Thread-Index: AQHNiaj3P6hPdFO/9UmvnYPXLZjhjZd4RTew Date: Mon, 3 Sep 2012 08:24:51 +0000 Message-ID: References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <20120903075032.GA29375@hysteria.proulx.com> In-Reply-To: <20120903075032.GA29375@hysteria.proulx.com> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.42.225] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Bob Proulx wrote (Monday, September 03, 2012 9:51 AM) > Jim Meyering wrote: > > Could you be thinking of some other rm? > > Coreutils' rm has rejected that for a long time: > > ... > > POSIX requires rm to reject any attempt to delete an explicitly specifi= ed > > "." or ".." argument (or any argument whose last component is one of th= ose): > > Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release > from twelve years ago in 2000, the oldest easily available to me, and > got this: > > $ /usr/bin/rm -rf . > rm: cannot remove .. or . > > So I guess GNU coreutils is in good company with traditional Unix > systems! It has definitely been that way for a long time. Seconded! SunOS 5.9: $ rm -rf . $ rm -r . rm of . is not allowed Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 04:33:45 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 08:33:45 +0000 Received: from localhost ([127.0.0.1]:35587 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8S6I-0005gb-L3 for submit@debbugs.gnu.org; Mon, 03 Sep 2012 04:33:44 -0400 Received: from mx.meyering.net ([88.168.87.75]:34759) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8S6F-0005gS-QR for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 04:33:41 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id F3E0760103; Mon, 3 Sep 2012 10:32:06 +0200 (CEST) From: Jim Meyering To: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is In-Reply-To: <20120903081744.26918.qmail@kosh.dhis.org> (Alan Curry's message of "Mon, 3 Sep 2012 03:17:44 -0500 (GMT+5)") References: <5043FA91.9070703@tlinx.org> <20120903081744.26918.qmail@kosh.dhis.org> Date: Mon, 03 Sep 2012 10:32:06 +0200 Message-ID: <87y5krik1l.fsf@rho.meyering.net> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Alan Curry wrote: > Bob Proulx writes: >> Jim Meyering wrote: >> > Could you be thinking of some other rm? >> > Coreutils' rm has rejected that for a long time: >> > ... >> > POSIX requires rm to reject any attempt to delete an explicitly specified >> > "." or ".." argument (or any argument whose last component is one of those): >> >> Hmm... Wow. I decided to check HP-UX 11.11, a now rather old release >> from twelve years ago in 2000, the oldest easily available to me, and >> got this: >> >> $ /usr/bin/rm -rf . >> rm: cannot remove .. or . >> >> So I guess GNU coreutils is in good company with traditional Unix >> systems! It has definitely been that way for a long time. > > Linux has the ability to actually remove a directory that is empty but still > referenced as the cwd of some process. This ability is non-traditional > (my fuzzy memory says it showed up some time in the 2.2 or 2.4 era). It's > worth considering whether this change should be reflected by a relaxation of > rm's traditional behavior. I see very little benefit in relaxing this restriction. Why introduce an incompatibility (slightly dangerous, even) with POSIX and with such long-standing behavior? > rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves If you use that, in general you would want to add quotes, in case there are spaces or other shell meta-characters: rm -rf "$PWD" > you in a directory so empty that ls -a reports no "." or ".." entries, and no > file can be created in the current directory. (open and stat and chdir still > work on . and .. though. They're magic.) From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 04:42:37 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 08:42:37 +0000 Received: from localhost ([127.0.0.1]:35598 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8SEu-0005uh-Na for submit@debbugs.gnu.org; Mon, 03 Sep 2012 04:42:37 -0400 Received: from c-67-162-91-36.hsd1.in.comcast.net ([67.162.91.36]:45722 helo=kosh.dhis.org) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1T8SEo-0005uU-Op for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 04:42:31 -0400 Received: (qmail 27038 invoked by uid 1000); 3 Sep 2012 08:40:58 -0000 Message-ID: <20120903084058.27037.qmail@kosh.dhis.org> From: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is To: jim@meyering.net (Jim Meyering) Date: Mon, 3 Sep 2012 03:40:58 -0500 (GMT+5) In-Reply-To: <87y5krik1l.fsf@rho.meyering.net> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Jim Meyering writes: > > Alan Curry wrote: > > > rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves > > If you use that, in general you would want to add quotes, > in case there are spaces or other shell meta-characters: > > rm -rf "$PWD" [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Jim Meyering writes: > > Alan Curry wrote: > > > rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves > > If you use that, in general you would want to add quotes, > in case there are spaces or other shell meta-characters: > > rm -rf "$PWD" [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Jim Meyering writes: > > Alan Curry wrote: > > > rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves > > If you use that, in general you would want to add quotes, > in case there are spaces or other shell meta-characters: > > rm -rf "$PWD" Well, when I do it I'm in zsh which has fixed that particular Bourne shell design error. -- Alan Curry From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 04:50:14 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 08:50:14 +0000 Received: from localhost ([127.0.0.1]:35606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8SMI-00065W-3j for submit@debbugs.gnu.org; Mon, 03 Sep 2012 04:50:14 -0400 Received: from mx.meyering.net ([88.168.87.75]:34813) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8SMF-00065P-P4 for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 04:50:12 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 9631960058; Mon, 3 Sep 2012 10:48:39 +0200 (CEST) From: Jim Meyering To: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is In-Reply-To: <20120903084058.27037.qmail@kosh.dhis.org> (Alan Curry's message of "Mon, 3 Sep 2012 03:40:58 -0500 (GMT+5)") References: <5043FA91.9070703@tlinx.org> <20120903084058.27037.qmail@kosh.dhis.org> Date: Mon, 03 Sep 2012 10:48:39 +0200 Message-ID: <87sjazija0.fsf@rho.meyering.net> Lines: 16 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Alan Curry wrote: > Jim Meyering writes: >> Alan Curry wrote: >> >> > rm -rf $PWD, meaning basically the same thing as rm -rf ., works, and leaves >> >> If you use that, in general you would want to add quotes, >> in case there are spaces or other shell meta-characters: >> >> rm -rf "$PWD" > > Well, when I do it I'm in zsh which has fixed that particular Bourne shell > design error. I use zsh on the command line, too (Go zsh! :-), but few have the luxury of being able to target zsh as their sole bourne-like shell interpreter. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 10:36:42 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 14:36:42 +0000 Received: from localhost ([127.0.0.1]:36441 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8XlZ-0007Mg-GC for submit@debbugs.gnu.org; Mon, 03 Sep 2012 10:36:41 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:51359 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8XlV-0007MY-Lq for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 10:36:39 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q83EZ2gr160091 for <12339@debbugs.gnu.org>; Mon, 3 Sep 2012 07:35:04 -0700 Message-ID: <5044C016.2030807@tlinx.org> Date: Mon, 03 Sep 2012 07:35:02 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: 12339@debbugs.gnu.org Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> In-Reply-To: <877gsbk1kz.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Jim Meyering wrote: > I see from your mention of "." below that you are objecting > to rm's refusal to remove "." or "..". --- I see from your response that you misunderstood what I wrote. There was no mention of "..". I wouldn't expect "rm" to crawl backward out of a "rm" in any even -- error message or not. > POSIX requires rm to reject any attempt to delete an explicitly specified > "." or ".." argument (or any argument whose last component is one of those): > > http://pubs.opengroup.org/onlinepubs/000095399/utilities/rm.html --- But you fail to follow the earlier stated POSIX requirement: .. " If this fails for any reason, rm shall write a diagnostic message to standard error, do nothing more with the current file, and go on to any remaining files." Specifically, in regards to a failure to remove a directory: For each entry contained in file, other than dot or dot-dot, the four steps listed here (1 to 4) shall be taken with the entry as if it were a file operand. The rm utility shall not traverse directories by following symbolic links into other parts of the hierarchy, but shall remove the links themselves." So for each entry in ".", except for . and .., rm is to traverse and remove them even after encountering an error -- which normally, it would only encounter at the end of removing all files in the directory. >> >> Sides -- it normally does depth-first traversal --- since you can't delete >> a dir with contents still in it -- so why different for '.'? > > Safety, I suspect. "." and ".." may not mean anything to a novice. ---- Again, ".." isn't the issue anymore than it should be skipped. What is at issue is the order of deletion (depth first), and it's not continuing to delete the other entires in the 'file' other than "." and ".." after encountering any errors (including a rejection to delete . and ..). So the error message is fine. But not deleting everything else in the dir isn't (at least judging from the POSIX doc you pointed me at... -- Thanks for the reference! From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 10:56:56 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 14:56:56 +0000 Received: from localhost ([127.0.0.1]:36455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Y5A-0007qA-0j for submit@debbugs.gnu.org; Mon, 03 Sep 2012 10:56:56 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:41546) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8Y55-0007q1-PW for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 10:56:53 -0400 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3X9Z3T458Vz4KK2c; Mon, 3 Sep 2012 16:55:17 +0200 (CEST) X-Auth-Info: PaD9V5W3ouvY3RU22pzhQjHshO5P5igTUXS5f8s6UHs= Received: from igel.home (ppp-88-217-117-77.dynamic.mnet-online.de [88.217.117.77]) by mail.mnet-online.de (Postfix) with ESMTPA id 3X9Z3T34pyzbbgS; Mon, 3 Sep 2012 16:55:17 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id E78BDCA2A4; Mon, 3 Sep 2012 16:55:16 +0200 (CEST) From: Andreas Schwab To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> X-Yow: This is PLEASANT! Date: Mon, 03 Sep 2012 16:55:16 +0200 In-Reply-To: <5044C016.2030807@tlinx.org> (Linda Walsh's message of "Mon, 03 Sep 2012 07:35:02 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Linda Walsh writes: > But you fail to follow the earlier stated POSIX > requirement: You failed to read the second paragraph: If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component) or if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 11:50:00 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 15:50:00 +0000 Received: from localhost ([127.0.0.1]:36508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8YuW-0000i9-89 for submit@debbugs.gnu.org; Mon, 03 Sep 2012 11:50:00 -0400 Received: from senmx12-mx.siemens-enterprise.com ([62.134.46.10]:42505) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8YuU-0000i0-7e for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 11:49:59 -0400 Received: from MCHP01HTC.global-ad.net (unknown [172.29.42.234]) by senmx12-mx.siemens-enterprise.com (Server) with ESMTP id BE9F323F03FF; Mon, 3 Sep 2012 17:48:23 +0200 (CEST) Received: from MCHP02MSX.global-ad.net ([169.254.4.126]) by MCHP01HTC.global-ad.net ([172.29.42.234]) with mapi id 14.02.0309.002; Mon, 3 Sep 2012 17:48:23 +0200 From: "Voelker, Bernhard" To: Andreas Schwab , Linda Walsh Subject: RE: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Thread-Topic: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Thread-Index: AQHNieQxP6hPdFO/9UmvnYPXLZjhjZd4tzRQ Date: Mon, 3 Sep 2012 15:48:23 +0000 Message-ID: References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> In-Reply-To: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.42.225] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Andreas Schwab wrote: > [...] read the second paragraph: > > If either of the files dot or dot-dot are specified as the basename > portion of an operand (that is, the final pathname component) or if > an operand resolves to the root directory, rm shall write a > diagnostic message to standard error and do nothing more with such > operands. Coreutils has already implemented an exception for the root directory: --no-preserve-root (whatever this would be useful for except investigating what'd happen in a VM ...). So it'd be possible to have another new switch to exceptionally permit removing ".", although - again - I don't see much gain over `rm -rf "$PWD"` or `find . -delete`. -1 from me. Moreover, I'd remove support for --[no-]preserve-root in rm: preserving is mandatory by POSIX, and not preserving is senseless. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 12:31:23 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 16:31:23 +0000 Received: from localhost ([127.0.0.1]:36565 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ZYY-0001gx-Do for submit@debbugs.gnu.org; Mon, 03 Sep 2012 12:31:22 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:55191 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ZYV-0001gm-0L for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 12:31:20 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q83GTg89176742 for <12339@debbugs.gnu.org>; Mon, 3 Sep 2012 09:29:44 -0700 Message-ID: <5044DAF6.2060706@tlinx.org> Date: Mon, 03 Sep 2012 09:29:42 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: 12339@debbugs.gnu.org Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Andreas Schwab wrote: > > If either of the files dot or dot-dot are specified as the basename > portion of an operand (that is, the final pathname component) or if > an operand resolves to the root directory, rm shall write a > diagnostic message to standard error and do nothing more with such > operands. --- You are right. This only further cements the worthlessness of the 2003 revision in it's claim as being a POSIX standard. The problem is that the initial standard didn't have many of these restrictions. I don't know about this specific one, but I bet it wasn't in *THE* POSIX standard. The idea of a POSIX standard was to make things compatible and provide a set of features for portable execution. Later revisions have mostly about adding restrictions. Most recently I observed a discussion on one of the posix lists about how further screw with people by restricting filename chars from the current set [^/\000] to [^/\000-\040]: "No more file names like this". This showed the braindead nature of the poster who forgot to restrict non-printing chars further up in the unicode range. ------------- Voelker, Bernhard wrote: > Andreas Schwab wrote: >> [...] read the second paragraph: >> >> If either of the files dot or dot-dot are specified as the basename >> portion of an operand (that is, the final pathname component) or if >> an operand resolves to the root directory, rm shall write a >> diagnostic message to standard error and do nothing more with such >> operands. > > Coreutils has already implemented an exception for the root > directory: --no-preserve-root (whatever this would be useful > for except investigating what'd happen in a VM ...). --- And by doing so has violated posix, since it doesn't say that if a switch is present, you can override the 2nd paragraph. If we are going to be stricly posix, it says if the arg is the root directory -- the util must have nothing more to do with the operand. Adding special "except if this", options doesn't make it posix compatible. It's interesting how people can rationalize that's it's ok to violate the standard for their special pet case, but when it comes to one's proposed by someone else, it's all "nope, not sorry -- and we can't remove _my_ feature for backwards compat reasons.."... Obviously, the same workaround that was prescribed for working around . would work for "/", namely: 'find / -delete'. If you are are going to rigidly adhere to a broken standard that is becoming more broken and restricted over time, you can't put in pet exceptions while using POSIX compat as a justification for not allowing other, more user friendly, options. so +1 to Bernhard for point that out, but a -1 to those who don't cite posix as an excuse, yet allow overrides that are non posix. More generally, -1 to the bad trend of taking a portable OS Exchange specification and turning it into a list of "thou shalt not's"... As if we need another list of those... The first has been a great excuse for oppression and mass murder... I wonder how high people elevate the holy P.O.S.ix. :-( --- Hey, I know... lets just add a new util 'r', does the job of rm and rmdir combined w/o unnecessary posix restrictions. r -f . (automatically does what is needed to remove "." -- including files beneath it). Interesting fact -- MS's "netsh", allows you to type the minimum number of chars of a command that are unambiguous to execute it. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 03 16:06:07 2012 Received: (at 12339) by debbugs.gnu.org; 3 Sep 2012 20:06:07 +0000 Received: from localhost ([127.0.0.1]:36817 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8cuM-0006j4-LB for submit@debbugs.gnu.org; Mon, 03 Sep 2012 16:06:07 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:44606) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8cuL-0006ix-AF for 12339@debbugs.gnu.org; Mon, 03 Sep 2012 16:06:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id A6E4A39E8015; Mon, 3 Sep 2012 13:04:30 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Uh-vZYMdUHPT; Mon, 3 Sep 2012 13:04:30 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5269439E8008; Mon, 3 Sep 2012 13:04:30 -0700 (PDT) Message-ID: <50450D4F.8010908@cs.ucla.edu> Date: Mon, 03 Sep 2012 13:04:31 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) I was about to suggest the following, on GNU/Linux: # Don't do this unless you know what you're doing! rm -fr /proc/self/cwd/ Except it doesn't work! Not even if I append '.': $ mkdir /tmp/victim $ cd /tmp/victim $ touch foo $ rm -fr /proc/self/cwd/ rm: cannot remove `/proc/self/cwd': Too many levels of symbolic links $ rm -fr /proc/self/cwd/. rm: cannot remove directory: `/proc/self/cwd/.' $ ls foo Aren't these bugs, at least? From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 01:22:44 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 05:22:44 +0000 Received: from localhost ([127.0.0.1]:37430 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8lb2-0003Pn-1g for submit@debbugs.gnu.org; Tue, 04 Sep 2012 01:22:44 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:50002) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8laz-0003Pe-5I for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 01:22:42 -0400 Received: from [192.168.2.108] (p4FF74DA9.dip.t-dialin.net [79.247.77.169]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0MFVyq-1TKudc3PnA-00ELGP; Tue, 04 Sep 2012 07:21:01 +0200 Message-ID: <50458FBB.5030401@bernhard-voelker.de> Date: Tue, 04 Sep 2012 07:20:59 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> In-Reply-To: <50450D4F.8010908@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:3C02sv4PmqWmJ/KhyWrC/STtRY5ZA/vzh7PdAYfaFsh MU9qCNUhKRt3OMXYQPH76bA1YqlwsE5lYYmZZCFJs4rhrR+VcW pw2wBboGT+NgwaiXi6gnpzTxw3ynwiDSLaadiNvCqi3LdM7F8t kRZdOFf0LsNkD2VT7DXMJKyA+nf7ssUKqv4HWjwE2L4DmMsA9F dQtJ+P8YY1trlU09prTciiggA9i3NOdfGWKtf8gB3bLY8e23nU KI8NCwcZivvN57UdUIPBmT6CH+aJSnM8RdmMjlN8cpqcxXWOt8 bvEmHfxH/x60KBtWhGcMocjiI3cxTVhJ1kLiZyexSD7CRoYHFu KkozItTQKD1TGAAn2Q6a2NFIqWdUwiehm1zOs7lnL X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/03/2012 10:04 PM, Paul Eggert wrote: > I was about to suggest the following, on GNU/Linux: > > # Don't do this unless you know what you're doing! > rm -fr /proc/self/cwd/ > > Except it doesn't work! Not even if I append '.': > > $ mkdir /tmp/victim > $ cd /tmp/victim > $ touch foo > $ rm -fr /proc/self/cwd/ > rm: cannot remove `/proc/self/cwd': Too many levels of symbolic links That is in rm_fts(): /* Perform checks that can apply only for command-line arguments. */ if (ent->fts_level == FTS_ROOTLEVEL) { if (strip_trailing_slashes (ent->fts_path)) ent->fts_pathlen = strlen (ent->fts_path); ent->fts_path is stripped from /proc/self/cwd/ to /proc/self/cwd. Then this: Ternary is_empty_directory; enum RM_status s = prompt (fts, ent, true /*is_dir*/, x, PA_DESCEND_INTO_DIR, &is_empty_directory); if (s == RM_OK && is_empty_directory == T_YES) { /* When we know (from prompt when in interactive mode) that this is an empty directory, don't prompt twice. */ s = excise (fts, ent, x, true); fts_skip_tree (fts, ent); } s is RM_OK, but is_empty_directory is T_NO, because it's no DIR ... The FTS loop continues and diagnoses ELOOP. That's the strace output: newfstatat(AT_FDCWD, "/proc/self/cwd/", {st_mode=S_IFDIR|0755, st_size=4096, ...}, AT_SYMLINK_NOFOLLOW) = 0 openat(AT_FDCWD, "/proc/self/cwd", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = -1 ELOOP (Too many levels of symbolic links) openat(AT_FDCWD, "/proc/self/cwd", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = -1 ELOOP (Too many levels of symbolic links) unlinkat(AT_FDCWD, "/proc/self/cwd", AT_REMOVEDIR) = -1 EACCES (Permission denied) The example applies to all symlinks to directories (i.e. not only to /proc/self/cwd): $ mkdir d $ touch d/file $ ln -s d dl $ rm -rv dl/ /home/berny/cu/src/rm: cannot remove ‘dl’: Too many levels of symbolic links However, in this case, unlinkat returns ENOTDIR: unlinkat(AT_FDCWD, "dl", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) > $ rm -fr /proc/self/cwd/. > rm: cannot remove directory: `/proc/self/cwd/.' > $ ls > foo That's the dot case. > Aren't these bugs, at least? The latter: no, because dot must not be removed. The former: maybe, but the question is what rm should remove: the symlink or the target? The info page is quiet about this. I tend to say it's okay as it is, because if someone wants to remove the target of a symlink,(s)he can always to $ rm -rv $(readlink -f dl) Only the diagnostic (ELOOP) looks a bit strange ... Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 01:33:59 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 05:34:00 +0000 Received: from localhost ([127.0.0.1]:37452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8llv-0003hg-L2 for submit@debbugs.gnu.org; Tue, 04 Sep 2012 01:33:59 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:58556) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8llt-0003hY-5c for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 01:33:58 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3B823A60025; Mon, 3 Sep 2012 22:32:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cdRJwym4v0rV; Mon, 3 Sep 2012 22:32:19 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D736539E8007; Mon, 3 Sep 2012 22:32:19 -0700 (PDT) Message-ID: <50459267.2020603@cs.ucla.edu> Date: Mon, 03 Sep 2012 22:32:23 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <50458FBB.5030401@bernhard-voelker.de> In-Reply-To: <50458FBB.5030401@bernhard-voelker.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On 09/03/2012 10:20 PM, Bernhard Voelker wrote: > the question is what rm should remove: > the symlink or the target? The convention in POSIX is that if a symlink is followed by '/', it's dereferenced. So this does appear to be a bug in coreutils 'rm'. I confirmed that the bug does not occur with Solaris 11 'rm': $ mkdir d $ touch d/file $ ln -s d dl $ ls -al * lrwxrwxrwx 1 eggert faculty 1 Sep 3 22:26 dl -> d d: total 16 drwxrwxr-x 2 eggert faculty 178 Sep 3 22:26 . drwxrwxr-x 3 eggert faculty 234 Sep 3 22:26 .. -rw-rw-r-- 1 eggert faculty 0 Sep 3 22:26 file $ rm -r dl/ $ ls -al * lrwxrwxrwx 1 eggert faculty 1 Sep 3 22:26 dl -> d Thanks for reminding me about "." and explaining why the other example is not a bug. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 06:42:08 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 10:42:08 +0000 Received: from localhost ([127.0.0.1]:37862 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8qa7-0002e3-Tk for submit@debbugs.gnu.org; Tue, 04 Sep 2012 06:42:08 -0400 Received: from mx.meyering.net ([88.168.87.75]:38524) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8qa4-0002dd-1t for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 06:42:05 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id EFCA860455; Tue, 4 Sep 2012 12:42:00 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <50459267.2020603@cs.ucla.edu> (Paul Eggert's message of "Mon, 03 Sep 2012 22:32:23 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <50458FBB.5030401@bernhard-voelker.de> <50459267.2020603@cs.ucla.edu> Date: Tue, 04 Sep 2012 12:42:00 +0200 Message-ID: <87sjaydq87.fsf@rho.meyering.net> Lines: 31 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Bernhard Voelker , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Paul Eggert wrote: > On 09/03/2012 10:20 PM, Bernhard Voelker wrote: >> the question is what rm should remove: >> the symlink or the target? > > The convention in POSIX is that if a symlink is > followed by '/', it's dereferenced. So this does > appear to be a bug in coreutils 'rm'. > > I confirmed that the bug does not occur with > Solaris 11 'rm': > > $ mkdir d > $ touch d/file > $ ln -s d dl > $ ls -al * > lrwxrwxrwx 1 eggert faculty 1 Sep 3 22:26 dl -> d Same for FreeBSD 9.0-RELEASE-p3: freebsd$ mkdir d; ln -s d s; /bin/rm -r s/; ls s@ But not with busybox 1.20.0-6: $ mkdir d; ln -s d s; busybox rm -r s/; ls d/ I have mixed feelings, but am leaning towards the Solaris 11/FreeBSD behavior. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 06:48:23 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 10:48:23 +0000 Received: from localhost ([127.0.0.1]:37879 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8qgB-0002nQ-EJ for submit@debbugs.gnu.org; Tue, 04 Sep 2012 06:48:23 -0400 Received: from moutng.kundenserver.de ([212.227.17.9]:62961) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8qg9-0002nJ-9U for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 06:48:22 -0400 Received: from [192.168.2.108] (p4FF74DA9.dip.t-dialin.net [79.247.77.169]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0LqU6b-1Tm1BP26Eb-00e1EF; Tue, 04 Sep 2012 12:48:06 +0200 Message-ID: <5045DC65.9030307@bernhard-voelker.de> Date: Tue, 04 Sep 2012 12:48:05 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <50458FBB.5030401@bernhard-voelker.de> <50459267.2020603@cs.ucla.edu> <87sjaydq87.fsf@rho.meyering.net> In-Reply-To: <87sjaydq87.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:kp6By2ORJ0kr0azofXQ1EHf49Gi0Hye0pKAzOxq//5c LEVabKDiGEyQeJvOd4X2hv2YKH1/rbKX9l6gtfYDLf4U8IH76N 9j02wsDtHyuvKeu4vjJ7a8t/72f3hBlaD5SJKZsJiidWlAR2HK AG6+hQp1j5ZUAEPC8EbwOxwqbuTXCT6eTA1NUJX2nIJr4JboOD eCbhJk3/89jVVidyBXIH5rR+1vyiTtFC/wsaHeogb0EioGEsY0 i1YYn43TjLwJoywKHiazMj45s5VVYdThxcmOxDsGHzqpV1gPsB QByKGnZBob1BHdWrcwOwrnZB23P8Tyuw6reQrHVYxIBBJCGHPl 8XIKuAxfAUEM1ju4F4q+hJacEyBp7GrMv5UroWS8p X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/04/2012 12:42 PM, Jim Meyering wrote: > I have mixed feelings, but am leaning towards the > Solaris 11/FreeBSD behavior. They must have fixed it for Solaris, here's an older one: $ uname -sr ; mkdir d; ln -s d s; /bin/rm -r s/; ls SunOS 5.9 d Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 08:55:53 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 12:55:53 +0000 Received: from localhost ([127.0.0.1]:37983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8sfV-0006VM-Ei for submit@debbugs.gnu.org; Tue, 04 Sep 2012 08:55:52 -0400 Received: from mx.meyering.net ([88.168.87.75]:38877) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8sfK-0006V5-BY for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 08:55:41 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id B295D600B2; Tue, 4 Sep 2012 14:55:35 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <50450D4F.8010908@cs.ucla.edu> (Paul Eggert's message of "Mon, 03 Sep 2012 13:04:31 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> Date: Tue, 04 Sep 2012 14:55:35 +0200 Message-ID: <877gsac5h4.fsf@rho.meyering.net> Lines: 108 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Paul Eggert wrote: > I was about to suggest the following, on GNU/Linux: > > # Don't do this unless you know what you're doing! > rm -fr /proc/self/cwd/ > > Except it doesn't work! Not even if I append '.': > > $ mkdir /tmp/victim > $ cd /tmp/victim > $ touch foo > $ rm -fr /proc/self/cwd/ > rm: cannot remove `/proc/self/cwd': Too many levels of symbolic links > $ rm -fr /proc/self/cwd/. > rm: cannot remove directory: `/proc/self/cwd/.' > $ ls > foo > > Aren't these bugs, at least? With the following patch, I see new behavior. It's an improvement, but we're still not there: $ mkdir -p d/e/f; ln -s d s; rm -r s/ rm: cannot remove 's/': Not a directory [Exit 1] $ find . ./s ./d Notice how it did traverse s/ into d/, and removed d/e and d/e/f. The only problem is that when it attempted to remove the command-line specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed: unlinkat(4, "d", 0) = 0 unlinkat(5, "f", AT_REMOVEDIR) = 0 unlinkat(4, "e", AT_REMOVEDIR) = 0 unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) rm: cannot remove 's/': Not a directory +++ exited with 1 +++ Now, this looks like a problem with unlinkat. Debating whether to add a test. Just writing the above, I know the answer. I will add a test. ================================================================== >From 958c553a84d37bdd8669ae68bfc8c4d4c5e7d2e1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 4 Sep 2012 14:40:11 +0200 Subject: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir These commands would evoke an invalid diagnostic: $ mkdir d && ln -s d s && env rm -r s/ rm: cannot remove 's': Too many levels of symbolic links remove.c was stripping trailing slashes from "s/" before passing the name to "rm". But a trailing slash may change the semantics, and thus should not be stripped. * src/remove.c (rm_fts): Do not strip trailing slashes. * tests/rm/v-slash.sh: Adapt to new expected output. * gnulib: Update to latest, for an improved fts.c that merely normalizes trailing slashes. Reported by Paul Eggert in discussion of http://bugs.gnu.org/12339 --- gnulib | 2 +- src/remove.c | 3 --- tests/rm/v-slash.sh | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gnulib b/gnulib index 68f693f..3a9002d 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 68f693ff1db33bf24695f0f42c62e7801966fd06 +Subproject commit 3a9002d3cc63da7110f133b1040d2d2b0aad8305 diff --git a/src/remove.c b/src/remove.c index 69faae6..847a5cc 100644 --- a/src/remove.c +++ b/src/remove.c @@ -433,9 +433,6 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) /* Perform checks that can apply only for command-line arguments. */ if (ent->fts_level == FTS_ROOTLEVEL) { - if (strip_trailing_slashes (ent->fts_path)) - ent->fts_pathlen = strlen (ent->fts_path); - /* If the basename of a command line argument is "." or "..", diagnose it and do nothing more with that argument. */ if (dot_or_dotdot (last_component (ent->fts_accpath))) diff --git a/tests/rm/v-slash.sh b/tests/rm/v-slash.sh index 504f4ff..ec77bd0 100755 --- a/tests/rm/v-slash.sh +++ b/tests/rm/v-slash.sh @@ -26,7 +26,7 @@ touch a/x || framework_failure_ rm --verbose -r a/// > out || fail=1 cat <<\EOF > exp || fail=1 removed 'a/x' -removed directory: 'a' +removed directory: 'a/' EOF compare exp out || fail=1 -- 1.7.12.176.g3fc0e4c From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 10:29:04 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 14:29:04 +0000 Received: from localhost ([127.0.0.1]:38550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8u7k-0000DG-1I for submit@debbugs.gnu.org; Tue, 04 Sep 2012 10:29:04 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:50795) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8u7i-0000Cy-IM for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 10:29:03 -0400 Received: from [192.168.2.108] (p4FF74DA9.dip.t-dialin.net [79.247.77.169]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0Lj8yB-1Tj55T3sid-00dTxE; Tue, 04 Sep 2012 16:28:49 +0200 Message-ID: <5046101F.8080108@bernhard-voelker.de> Date: Tue, 04 Sep 2012 16:28:47 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> In-Reply-To: <877gsac5h4.fsf@rho.meyering.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:oKAfquhkXtO46spDekBhZJa0N+YX8iU9wdJrkRzDa4F FBySC3bo8OYEH21fBbS33qf34iCmSERhDlm9vooD3oruPBMFQR A516mvKeNuzEpKvDQ2RZAyMV1zWTOHQudkVlJSEj4swv2h4mKL ETDoN2HsjDCNIUQh0b45A9vWB91HM3EWsUrjG0u8oH/SptdplQ pL43MIROA3xEE34MegJTtXUZ8BNLGHpvFvLsyexVh4uTT4rzJG ownhK/ODx/SUAX355IeTIrlyRvumEwHJhsmppWWuxMqNN3mFpc WBEtIdtlFmw5rWMH5+4Zmv4dd1xfbf/FXqhMV7oDPe4PcBrdjQ fqOmx2U6pCERFMdkPAN151Xjl0ibNf7J14NV7hGGr X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/04/2012 02:55 PM, Jim Meyering wrote: > With the following patch, I see new behavior. > It's an improvement, but we're still not there: > > $ mkdir -p d/e/f; ln -s d s; rm -r s/ > rm: cannot remove 's/': Not a directory > [Exit 1] > $ find > . > ./s > ./d > > Notice how it did traverse s/ into d/, and removed d/e and d/e/f. > The only problem is that when it attempted to remove the command-line > specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed: > > unlinkat(4, "d", 0) = 0 > unlinkat(5, "f", AT_REMOVEDIR) = 0 > unlinkat(4, "e", AT_REMOVEDIR) = 0 > unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) > rm: cannot remove 's/': Not a directory > +++ exited with 1 +++ > > Now, this looks like a problem with unlinkat. Hmm, what about dereferencing command line symlinks with trailing slashes _before_ entering the FTS loop instead? Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 11:02:47 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 15:02:47 +0000 Received: from localhost ([127.0.0.1]:38582 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ueM-00010N-Jo for submit@debbugs.gnu.org; Tue, 04 Sep 2012 11:02:47 -0400 Received: from mx.meyering.net ([88.168.87.75]:39213) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8ueK-00010E-HW for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 11:02:45 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 7BB6460121; Tue, 4 Sep 2012 17:02:42 +0200 (CEST) From: Jim Meyering To: Bernhard Voelker Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <5046101F.8080108@bernhard-voelker.de> (Bernhard Voelker's message of "Tue, 04 Sep 2012 16:28:47 +0200") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> Date: Tue, 04 Sep 2012 17:02:42 +0200 Message-ID: <87mx15bzl9.fsf@rho.meyering.net> Lines: 35 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Bernhard Voelker wrote: > On 09/04/2012 02:55 PM, Jim Meyering wrote: >> With the following patch, I see new behavior. >> It's an improvement, but we're still not there: >> >> $ mkdir -p d/e/f; ln -s d s; rm -r s/ >> rm: cannot remove 's/': Not a directory >> [Exit 1] >> $ find >> . >> ./s >> ./d >> >> Notice how it did traverse s/ into d/, and removed d/e and d/e/f. >> The only problem is that when it attempted to remove the command-line >> specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed: >> >> unlinkat(4, "d", 0) = 0 >> unlinkat(5, "f", AT_REMOVEDIR) = 0 >> unlinkat(4, "e", AT_REMOVEDIR) = 0 >> unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) >> rm: cannot remove 's/': Not a directory >> +++ exited with 1 +++ >> >> Now, this looks like a problem with unlinkat. > > Hmm, what about dereferencing command line symlinks with trailing > slashes _before_ entering the FTS loop instead? Thanks, but I'm pretty sure that would be too much work to perform on any slash-decorated operand. Besides, I'm not 100% sold on the idea that that final unlinkat call should be creating a dangling symlink (i.e., by removing the directory to which "s" points). From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 11:39:44 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 15:39:44 +0000 Received: from localhost ([127.0.0.1]:38652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8vE6-0001pj-SU for submit@debbugs.gnu.org; Tue, 04 Sep 2012 11:39:43 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:50464) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8vE5-0001pb-1R for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 11:39:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id CFCAE39E8015; Tue, 4 Sep 2012 08:39:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cw6sDIfZhGWo; Tue, 4 Sep 2012 08:39:38 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5208F39E8008; Tue, 4 Sep 2012 08:39:38 -0700 (PDT) Message-ID: <504620B5.2040406@cs.ucla.edu> Date: Tue, 04 Sep 2012 08:39:33 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> In-Reply-To: <87mx15bzl9.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Bernhard Voelker , Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On 09/04/2012 08:02 AM, Jim Meyering wrote: > I'm not 100% sold on the idea that that final unlinkat > call should be creating a dangling symlink (i.e., by removing > the directory to which "s" points). But that's what rmdir() and the rmdir command are supposed to do. That much, at least, is pretty clearly specified by POSIX 2008. But now I see that coreutils rmdir doesn't do that: $ mkdir a $ ln -s a b $ rmdir b/ rmdir: failed to remove 'b/': Not a directory Solaris 10 rmdir gets it right. Interestingly enough, Solaris 10's port of coreutils rmdir (/opt/sfw/bin/rmdir) also gets it right: it executes rmdir("b/"), which removes the directory. This is coreutils 5.93, so I assume at some point there was a regression? A bit more investigation shows that rmdir("b/") fails on Linux 3.2.0, succeeds on Solaris 10, but fails on Solaris 11! Curiouser and curiouser. This means the Solaris 11 rmdir command agrees with GNU/Linux and they both disagree with POSIX and with Solaris 10. The problem also affects other commands. For example, POSIX says this should work: $ mkdir a $ ln -s a b $ mv b/ c and should rename a to c. It does work, on Solaris 11, but with coreutils it fails and reports mv: cannot move 'b/' to 'c': Not a directory From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 13:46:25 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 17:46:25 +0000 Received: from localhost ([127.0.0.1]:38751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xCi-0004hd-Qp for submit@debbugs.gnu.org; Tue, 04 Sep 2012 13:46:25 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:52691 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xCb-0004hQ-7e for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 13:46:23 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q84HkA2B493356; Tue, 4 Sep 2012 10:46:12 -0700 Message-ID: <50463E62.2010101@tlinx.org> Date: Tue, 04 Sep 2012 10:46:10 -0700 From: "Linda A. Walsh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org>, Paul Eggert Subject: Re: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Jim Meyering wrote: > These commands would evoke an invalid diagnostic: > $ mkdir d && ln -s d s && env rm -r s/ > rm: cannot remove 's': Too many levels of symbolic links > remove.c was stripping trailing slashes from "s/" before passing > the name to "rm". But a trailing slash may change the semantics, > and thus should not be stripped. > I would assert that the trailing "." shouldn't be stripped either. If the directory is a mount point -- then "." would indicate the contents of the mount point -- being after the "/", while the "/" would be the mount point itself. In my case, I wanted to delete everything in the mount point. Removal of the mount point itself would ideally unmount the 'fs', but I won't hold my breath on that one (and leave the root inode of the file system in the unmounted file system -- thus I've effectively removed "." from mountpoint/. Which is different from the "." of a directory entry -- NO I'm not asking for this as a feature, I'm just saying it would be a valid semantic paradigm"). I WOULD want rm dir foobar/. to remove all contents in the directory before failing on ".". The original version of posix didn't have this restriction/problem. POSIX is portability standard -- it should not be regarded as a restrictive standard, unless not doing so would hinder portability. In effect, they are disallowing OS's to make extensions beyond what they allow in the newer standards... That goes WAY beyond a portability standard... From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 13:50:01 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 17:50:01 +0000 Received: from localhost ([127.0.0.1]:38755 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xGC-0004mN-Qm for submit@debbugs.gnu.org; Tue, 04 Sep 2012 13:50:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17700) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xGA-0004mE-3n for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 13:49:59 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q84HnmeZ002477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Sep 2012 13:49:48 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q84HnldA013774; Tue, 4 Sep 2012 13:49:48 -0400 Message-ID: <50463F3B.4040008@redhat.com> Date: Tue, 04 Sep 2012 11:49:47 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> In-Reply-To: <50463E62.2010101@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig72B35B14187E561A7C17CE71" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -7.1 (-------) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , Paul Eggert , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -7.1 (-------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig72B35B14187E561A7C17CE71 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/04/2012 11:46 AM, Linda A. Walsh wrote: > POSIX is portability standard -- it should not > be regarded as a restrictive standard, unless not doing so would hinder= > portability. In effect, they are disallowing OS's to make extensions > beyond > what they allow in the newer standards... That's where you are wrong. POSIX _does_ allow OS's to make extensions beyond the standard. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig72B35B14187E561A7C17CE71 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQRj87AAoJEKeha0olJ0Nq/FQH/0KYL3rNdzrNTJIddpniNpFM Ang4mThqakzNvEWSiUED0agCadC547J4loWZzFIqYlfAnn9zngSdTicFLZxvahIj BvogZPtlolu5LTcGK1brAn7Z8TW194WJytFMW19qEoX6r3v0Dp1k4MIEjvtaMQ57 zd0nT5Wf2Rs6j8MtlpqC59rQ61wsLVuKQxUf+RQmXlMF6zCmTXG9B48gDVUHBpLi qFix6AThP9IPC0F3dcwI3QydGETL08IYdsHWpKjdLDoouNj3tcRs5nJ1Ph8pVHjh W/AVXQ/SW2jHjSpE4ufw6gwTVYnZSuh23e0Q/qUTnER1sUdw1XR6M6GK48QIWoA= =MUY7 -----END PGP SIGNATURE----- --------------enig72B35B14187E561A7C17CE71-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 13:53:08 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 17:53:08 +0000 Received: from localhost ([127.0.0.1]:38760 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xJE-0004rB-Cm for submit@debbugs.gnu.org; Tue, 04 Sep 2012 13:53:08 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:57818) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xJC-0004r4-HO for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 13:53:07 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4D9B239E8019; Tue, 4 Sep 2012 10:53:04 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aohA6YlHQNAj; Tue, 4 Sep 2012 10:53:03 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id C32A839E8008; Tue, 4 Sep 2012 10:53:03 -0700 (PDT) Message-ID: <50464000.8000603@cs.ucla.edu> Date: Tue, 04 Sep 2012 10:53:04 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> In-Reply-To: <50463E62.2010101@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On 09/04/2012 10:46 AM, Linda A. Walsh wrote: > I would assert that the trailing "." shouldn't be stripped either. If we were designing anew, I'd be inclined to agree with you. But there are probably people expecting the standard behavior now, and there's an argument for not departing from the standard unless there's a good reason. Here, if we can provide a command "rm -fr foo/" to do what you want, then I hope it's merely a minor glitch that "rm -fr foo/." doesn't do what you want. After all, the version without the "." is easier to type, and it's more convenient with shells that autocomplete, so the fact that POSIX requires failure for the version with the "." shouldn't be that big a deal. ("rm -fr foo/" doesn't work right either, but we're looking into that....) From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 13:58:05 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 17:58:05 +0000 Received: from localhost ([127.0.0.1]:38776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xO1-0004yE-6k for submit@debbugs.gnu.org; Tue, 04 Sep 2012 13:58:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24603) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xNy-0004y7-K0 for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 13:58:03 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q84Hw0QC001298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Sep 2012 13:58:00 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q84HvxC1005764; Tue, 4 Sep 2012 13:57:59 -0400 Message-ID: <50464127.7080408@redhat.com> Date: Tue, 04 Sep 2012 11:57:59 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <5044DAF6.2060706@tlinx.org> In-Reply-To: <5044DAF6.2060706@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig0F30AA8747E57D9E758163DC" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Spam-Score: -7.1 (-------) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -7.1 (-------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0F30AA8747E57D9E758163DC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/03/2012 10:29 AM, Linda Walsh wrote: >> Coreutils has already implemented an exception for the root >> directory: --no-preserve-root (whatever this would be useful >> for except investigating what'd happen in a VM ...). > --- > And by doing so has violated posix, since it doesn't say that if > a switch is present, you can override the 2nd paragraph. Unfortunately, you are wrong on your interpretation of POSIX. POSIX specifically allows implementations to add extensions, such as --no-preserve-root, and that such extensions may explicitly override the required behavior for the application when no extensions are used. After all, that's what extensions are for. In other words, coreutils is _not_ violating POSIX by adding --no-preserve-root as an extension. > If we > are going to be stricly posix, it says if the arg is the root > directory -- the util must have nothing more to do with the operand. POSIX does indeed say that, but it applies only when you use 'rm' in a standards-compliant invocation; the moment you add --no-preserve-root to your invocation, you are no longer using a standards-compliant invocation, so all bets are off as far as POSIX goes. >=20 > If you are are going to rigidly adhere to a broken standard that is > becoming more broken and restricted over time, you can't put in > pet exceptions while using POSIX compat as a justification for > not allowing other, more user friendly, options. If you are going to continually gripe about POSIX rather than constructively contribute towards improving it, then we have no reason to pay attention to your gripes. You can become a member of the Austin Group at no monetary cost, and contribute bug reports to places where you think the standard has got things wrong. But griping to the coreutils list is not the way to get POSIX fixed. If, on the other hand, you are arguing for more long-option extensions to coreutils, then please contribute patches rather than gripes. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig0F30AA8747E57D9E758163DC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQRkEnAAoJEKeha0olJ0NqG0UH/j1XP2DIRSriVVbu0k5GASVE NzCPXqnuu4C5NAY5OZYG4sM/MiMCPhe5nEHd2VJfKAyif6cahhDaT9GSs28OdAVt QMDliQeRmirxrq6J+PGqe06F+Za2xyEemSbY2guQ7mdx+iFL4ezHpN0o2ssIEpJQ vzYJbNrZ+nqj5E46k6KR5KpidxUls2sSDReBaBH28XAwSp3CL7hcWuzC+h2yivvz pd2ly88i80ngnG9246EuJtNp0o79AW0i6HfPkpE0dx3pXLvrss62xaqh3AzU6vk5 fCVbLVGGr+raSrXm3XJw1vA6bA+ms1DL2xUN7HqWCXvUwkXgiEXoITD5O1KfqZU= =RNFJ -----END PGP SIGNATURE----- --------------enig0F30AA8747E57D9E758163DC-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 14:07:29 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 18:07:29 +0000 Received: from localhost ([127.0.0.1]:38787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xX7-0005Bm-GC for submit@debbugs.gnu.org; Tue, 04 Sep 2012 14:07:29 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:53954 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T8xX5-0005Bf-FO for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 14:07:28 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q84I7Me9497472; Tue, 4 Sep 2012 11:07:24 -0700 Message-ID: <5046435A.5080902@tlinx.org> Date: Tue, 04 Sep 2012 11:07:22 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <5044DAF6.2060706@tlinx.org> <50464127.7080408@redhat.com> In-Reply-To: <50464127.7080408@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) Eric Blake wrote: > POSIX does indeed say that, but it applies only when you use 'rm' in a > standards-compliant invocation; the moment you add --no-preserve-root to > your invocation, you are no longer using a standards-compliant > invocation, so all bets are off as far as POSIX goes. -- Which under GNU tools has mean when POSIX_CORRECTLY=1 is set in the environment. It is not. There is nothing preventing tools functioning in a more userfriendly manner than POSIX allows in the absence of a request for POSIX_CORRECTLY. Unless you are telling me that all GNU utils have removed that and always run in POSIX mode by default. POSIX was designed to be a lowest common denominator -- not a highest level allowed -- that's why under Gnu/Linux it's only under a specific request for POSIX compat that lowest level functionality is enforced. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 19:22:29 2012 Received: (at 12339) by debbugs.gnu.org; 4 Sep 2012 23:22:29 +0000 Received: from localhost ([127.0.0.1]:39047 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T92Rw-0003ur-Hd for submit@debbugs.gnu.org; Tue, 04 Sep 2012 19:22:29 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:36778 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T92Rt-0003ui-4a for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 19:22:27 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q84NLr2U564191; Tue, 4 Sep 2012 16:21:55 -0700 Message-ID: <50468D11.9030607@tlinx.org> Date: Tue, 04 Sep 2012 16:21:53 -0700 From: "Linda A. Walsh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> In-Reply-To: <50464000.8000603@cs.ucla.edu> Content-Type: multipart/alternative; boundary="------------020600050901080406090805" X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) This is a multi-part message in MIME format. --------------020600050901080406090805 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > On 09/04/2012 10:46 AM, Linda A. Walsh wrote: > >> I would assert that the trailing "." shouldn't be stripped either. >> > > If we were designing anew, I'd be inclined to agree with you. > But there are probably people expecting the standard behavior now, > ---- i.e. expecting it to do nothing useful other than issue an error? Who would type that in, expecting that? What useful purpose does it serve? > and there's an argument for not departing from the standard > unless there's a good reason. > Usability, Expressiveness. > Here, if we can provide a command "rm -fr foo/" to do what you > want, then I hope it's merely a minor glitch that "rm -fr foo/." > Ok, will foo/ remove the contents only and not the directory? If so, then it's a replacement -- that sounds like what is being talked about .. yes? It seems so fragile -- because some utils require the /. to make sure you don't ALSO remove the directory. if I remove foo/. I know, unambigously, that the directory "foo won't be removed. With "foo/", it will depend on the program. That means other programs will have to change to be compat with the new standard -- when they were all compat before when foo/. did a recursive remove and gave an error at the end about can't remove ".".... That was a behavior I've relied on...(i.e. if it really did remove ".", that would defeat the purpose of the of the safety invocation. However, adding foo/ -- does that imply that ./ will also work? so now rm -fr ./ will work? That's awfully close to "rm -fr /." just as rm -fr ./* is close to rm -fr /.* I've never relied on rm to protect me from rm -fr /, which is why I have tended to use relative paths with "." and ending in "." if I wanted to keep the dir, or not -- as there is ALOT of code out there that removes trailing "slashes"... (like the code under discussion -- perfect example)....it is by far not the only one to treat '/' as option at the end of a path. --------------020600050901080406090805 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q84NLr2U564191 Paul Eggert wrote:
On 09/04/2012 10:46 AM, Linda A. Walsh wrote:
  
I would assert that the trailing "." shouldn't be stri=
pped either.
    

If we were designing anew, I'd be inclined to agree with you.
But there are probably people expecting the standard behavior now,
  
----
i.e. expecting it to do nothing useful other than issue an error?

Who would type that in, expecting that?

What useful purpose does it serve?


and there's an argument for not departing from the stand=
ard
unless there's a good reason.
  
Usability, Expressiveness.

Here, if we can provide a command "rm -fr foo/" to do wh=
at you
want, then I hope it's merely a minor glitch that "rm -fr foo/."
  
Ok, will foo/ remove the contents only and not the directory?

If so, then it's a replacement -- that sounds like what is being
talked about .. yes?

It seems so fragile -- because some utils require the /. to make sure you don't
ALSO remove the directory.

if I remove foo/.

I know, unambigously, that the directory "foo won't be removed.

With "foo/", it will depend on the program.

That means other programs will have to change to be compat with the
new standard -- when they were all compat before when
foo/. did a recursive remove and gave an error at the end about
can't remove "."....

That was a behavior I've relied on...(i.e. if it really did remove
".", that would defeat the purpose of the of the safety invocation.

However, adding foo/ -- does that imply that ./ will also work?

so now rm -fr ./ will work?=C2=A0=C2=A0 That's awfully close to "rm -fr /= ."
just as rm -fr ./* is close to rm -fr /.*

I've never relied on rm to protect me from rm -fr /, which
is why I have tended to use relative paths with "." and ending
in "." if I wanted to keep the dir, or not -- as there is
ALOT of code out there that removes trailing "slashes"...

(like the code under discussion -- perfect example)....it is by far not the only one to treat '/' as option at the end of a path.


--------------020600050901080406090805-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 20:49:25 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 00:49:25 +0000 Received: from localhost ([127.0.0.1]:39118 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T93o4-0005qY-7Y for submit@debbugs.gnu.org; Tue, 04 Sep 2012 20:49:24 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:48932) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T93o1-0005qP-27 for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 20:49:22 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 610B4A60032; Tue, 4 Sep 2012 17:49:16 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HL-b80XK9fPD; Tue, 4 Sep 2012 17:49:16 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 91F6DA60031; Tue, 4 Sep 2012 17:49:15 -0700 (PDT) Message-ID: <5046A18E.6030808@cs.ucla.edu> Date: Tue, 04 Sep 2012 17:49:18 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> In-Reply-To: <50468D11.9030607@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On 09/04/2012 04:21 PM, Linda A. Walsh wrote:> Paul Eggert wrote: > expecting it to do nothing useful other than issue an error? Sure. People might expect the utility to complain about what they consider to be obvious typos, rather than to remove files they don't expect to be removed. For example: rm -fr .* safely removes all file names beginning with "." in the working directory, without inadvertently removing file names that do not begin with ".", or files in the parent directory. I can see people being used to this sort of thing, and being annoyed greatly if we change it. > Ok, will foo/ remove the contents only and not the directory? No, "rm -fr foo/" removes the directory too. > It seems so fragile -- because some utils require the /. to make > sure you don't ALSO remove the directory. Which utilities are those? The standard POSIX style is that foo/ names the directory. > However, adding foo/ -- does that imply that ./ will also work? No, "./" is treated as ".". Sorry. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 04 21:56:48 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 01:56:48 +0000 Received: from localhost ([127.0.0.1]:39159 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T94rI-0007YA-2u for submit@debbugs.gnu.org; Tue, 04 Sep 2012 21:56:48 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:41885 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T94rF-0007Y1-T9 for 12339@debbugs.gnu.org; Tue, 04 Sep 2012 21:56:46 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q851tqkS588034; Tue, 4 Sep 2012 18:55:54 -0700 Message-ID: <5046B128.8010409@tlinx.org> Date: Tue, 04 Sep 2012 18:55:52 -0700 From: "Linda A. Walsh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> In-Reply-To: <5046A18E.6030808@cs.ucla.edu> Content-Type: multipart/alternative; boundary="------------020301050103030700000708" X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) This is a multi-part message in MIME format. --------------020301050103030700000708 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > On 09/04/2012 04:21 PM, Linda A. Walsh wrote:> Paul Eggert wrote: > > >> expecting it to do nothing useful other than issue an error? >> > > Sure. People might expect the utility to complain about > what they consider to be obvious typos, rather than to > remove files they don't expect to be removed. For example: > > rm -fr .* > > safely removes all file names beginning with "." in the > working directory, without inadvertently removing file names > that do not begin with ".", or files in the parent > directory. I can see people being used to this sort of > thing, and being annoyed greatly if we change it. > ---- i wouldn't regard that as safe. I always use rm -fr .[^.]* Why is that interfaces must sync to the lowest level. unix was NOT supposed to be that way. > >> Ok, will foo/ remove the contents only and not the directory? >> > > No, "rm -fr foo/" removes the directory too. > So how do delete all files in the directory without wild cards? (as you don't know how or if they will be expanded). (only VERY recently has bash included "." in "*" -- it used to be ignored and still is if you have flags set to ignore it. Shells don't consistently expand wildcards, and the OS doesn't expand them at all (i.e. when passed in 'exec')... This is what I mean about useful features being removed in order to dumb down the interface -- as dir/" also tries to remove the dir... which isn't likely to work on a mount point. --------------020301050103030700000708 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q851tqkS588034 Paul Eggert wrote:
On 09/04/2012 04:21 PM, Linda A. Walsh wrote:> Paul E=
ggert wrote:

  
expecting it to do nothing useful other than issue an =
error?
    

Sure.  People might expect the utility to complain about
what they consider to be obvious typos, rather than to
remove files they don't expect to be removed.  For example:

  rm -fr .*

safely removes all file names beginning with "." in the
working directory, without inadvertently removing file names
that do not begin with ".", or files in the parent
directory.  I can see people being used to this sort of
thing, and being annoyed greatly if we change it.
  
----
=C2=A0=C2=A0 i wouldn't regard that as safe.

I always use rm -fr .[^.]*

Why is that interfaces must sync to the lowest level.

unix was NOT supposed to be that way.

  
Ok, will foo/ remove the contents only and not the dir=
ectory?
    

No, "rm -fr foo/" removes the directory too.
  
So how do delete all files in the directory without wild cards?

(as you don't know how or if they will be expanded).

(only VERY recently has bash included "." in "*" -- it used to be ignored and
still is if you have flags set to ignore it.

Shells don't consistently expand wildcards, and the OS doesn't expand them
at all (i.e. when passed in 'exec')...

This is what I mean about useful features being removed in order to dumb down
the interface -- as dir/" also tries to remove the dir... which isn't
likely to work on a mount point.


--------------020301050103030700000708-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 02:25:56 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 06:25:56 +0000 Received: from localhost ([127.0.0.1]:39372 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T993e-00057T-TD for submit@debbugs.gnu.org; Wed, 05 Sep 2012 02:25:55 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:58471) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T993Y-00057C-3h for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 02:25:46 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 2B1A2A60031; Tue, 4 Sep 2012 23:25:38 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qMz9z9Kf5nx3; Tue, 4 Sep 2012 23:25:37 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A5907A6002C; Tue, 4 Sep 2012 23:25:37 -0700 (PDT) Message-ID: <5046F058.6020005@cs.ucla.edu> Date: Tue, 04 Sep 2012 23:25:28 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> In-Reply-To: <5046B128.8010409@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) On 09/04/2012 06:55 PM, Linda A. Walsh wrote: > So how do delete all files in the directory without wild cards? Why tie your hands behind your back? Use wild cards: cd DIRECTORY && rm -fr * .[!.] .??* If you do this a lot, put it into a shell script. It's not like the need is all that common, for most people, but if you need it that's what scripts are for. If you fiddle with your shell settings about how wildcards are expanded, make sure your script does wildcards in the standard way. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 02:41:47 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 06:41:47 +0000 Received: from localhost ([127.0.0.1]:39383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T99J4-0005Us-Ou for submit@debbugs.gnu.org; Wed, 05 Sep 2012 02:41:47 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:63698) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T99J0-0005Ui-IZ for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 02:41:43 -0400 Received: from [192.168.2.108] (p4FF75DB8.dip.t-dialin.net [79.247.93.184]) by mrelayeu.kundenserver.de (node=mreu3) with ESMTP (Nemesis) id 0LiJtA-1TjJX10AYe-00ceXe; Wed, 05 Sep 2012 08:41:35 +0200 Message-ID: <5046F41E.8000403@bernhard-voelker.de> Date: Wed, 05 Sep 2012 08:41:34 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> In-Reply-To: <5046F058.6020005@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:MUJXt2SSpPWSnjSs1Rtv8S/kbmdnxpIR5ztBsfsll/C v8CTUEMDfXEehkmE22sOdb8nCbTKgtnDlVeoTDXLcrBhC9Vq6n HKY/BhnjhRiqR/+laHd3Tna2+K3LW5X+Mh4vuBBRVCdNri18Yn EYIoFx/IX+xMdGh5+NAVMa/cK9sUHgpCM5svM/DmIuJG4e97vk v0NSDBSUFBC5enJwY0gDO+SbM+3maR4wvbTLFdzPaFPI3lgh3H tOUUNkuq8eU3o7vk9UJhHgOltyyAG4PHVlG29z8IHGLcj5ljF9 B/ge3/3aqmmZD7FrmztST14xIPkw8B+cTDk6x4WHe2q4T2WIle ycf+sr6yWu2mokGRgLDxtVwj/ZYOackEJVd26rldb X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "Linda A. Walsh" , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/05/2012 08:25 AM, Paul Eggert wrote: > On 09/04/2012 06:55 PM, Linda A. Walsh wrote: > >> So how do delete all files in the directory without wild cards? > > Why tie your hands behind your back? Use wild cards: > > cd DIRECTORY && rm -fr * .[!.] .??* > > If you do this a lot, put it into a shell script. > It's not like the need is all that common, for most people, > but if you need it that's what scripts are for. > > If you fiddle with your shell settings about > how wildcards are expanded, make > sure your script does wildcards in the standard way. Exactly, we're now at the point where globbing is the topic, much way away from coreutils and rm. Bash knows dotglob: $ mkdir d ; cd d $ touch .a b ; mkdir c $ ( shopt -s dotglob ; rm -rv * ) removed `.a' removed `b' removed directory: `c' Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 02:58:57 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 06:58:57 +0000 Received: from localhost ([127.0.0.1]:39399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T99Zf-0005s4-VL for submit@debbugs.gnu.org; Wed, 05 Sep 2012 02:58:57 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:52013 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T99Zd-0005ru-Kh for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 02:58:54 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q856wclV632704; Tue, 4 Sep 2012 23:58:40 -0700 Message-ID: <5046F81E.5000806@tlinx.org> Date: Tue, 04 Sep 2012 23:58:38 -0700 From: "Linda A. Walsh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> In-Reply-To: <5046F058.6020005@cs.ucla.edu> Content-Type: multipart/alternative; boundary="------------030901030806070207080409" X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) This is a multi-part message in MIME format. --------------030901030806070207080409 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > On 09/04/2012 06:55 PM, Linda A. Walsh wrote: > > >> So how do delete all files in the directory without wild cards? >> > > Why tie your hands behind your back? Use wild cards: > > cd DIRECTORY && rm -fr * .[!.] .??* > > If you do this a lot, put it into a shell script. > It's not like the need is all that common, for most people, > but if you need it that's what scripts are for. > > If you fiddle with your shell settings about > how wildcards are expanded, make > sure your script does wildcards in the standard way. > --- I'm not talking for interactive use... I'm talking for use in a script that might run on systems that are not mine -- so I can't rely on shell settings. --------------030901030806070207080409 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q856wclV632704 Paul Eggert wrote:
On 09/04/2012 06:55 PM, Linda A. Walsh wrote:
=20
  
So how do delete all files in the directory without wi=
ld cards?
    

Why tie your hands behind your back?  Use wild cards:

  cd DIRECTORY && rm -fr * .[!.] .??*

If you do this a lot, put it into a shell script.
It's not like the need is all that common, for most people,
but if you need it that's what scripts are for.

If you fiddle with your shell settings about
how wildcards are expanded, make
sure your script does wildcards in the standard way.
  
---
=C2=A0=C2=A0=C2=A0 I'm not talking for interactive use... I'm talking for= use in a script
that might run on systems that are not mine -- so I can't rely on shell settings.

--------------030901030806070207080409-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 10:35:02 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 14:35:02 +0000 Received: from localhost ([127.0.0.1]:40448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Gh4-0001EK-Dd for submit@debbugs.gnu.org; Wed, 05 Sep 2012 10:35:02 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:45493) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Gh1-0001E0-HM for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 10:35:00 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id D4CD2A60035; Wed, 5 Sep 2012 07:34:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id klewxI50ZbBl; Wed, 5 Sep 2012 07:34:51 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6B9EFA60034; Wed, 5 Sep 2012 07:34:51 -0700 (PDT) Message-ID: <50476303.70505@cs.ucla.edu> Date: Wed, 05 Sep 2012 07:34:43 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> <5046F81E.5000806@tlinx.org> In-Reply-To: <5046F81E.5000806@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/04/2012 11:58 PM, Linda A. Walsh wrote: > I'm not talking for interactive use... I'm talking for use in a script > that might run on systems that are not mine -- so I can't rely on shell settings. Yes you can. Just start the script with "#!/bin/sh", as usual. When invoked that way, Bash and other shells are POSIX-compliant in this area. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 10:51:20 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 14:51:20 +0000 Received: from localhost ([127.0.0.1]:40488 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Gwp-0001dp-Tf for submit@debbugs.gnu.org; Wed, 05 Sep 2012 10:51:20 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:39113 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Gwo-0001dh-5y for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 10:51:19 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q85Ep6lD729920; Wed, 5 Sep 2012 07:51:08 -0700 Message-ID: <504766DB.4050606@tlinx.org> Date: Wed, 05 Sep 2012 07:51:07 -0700 From: "Linda A. Walsh" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> <5046F81E.5000806@tlinx.org> <50476303.70505@cs.ucla.edu> In-Reply-To: <50476303.70505@cs.ucla.edu> Content-Type: multipart/alternative; boundary="------------010004070607090607090506" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is a multi-part message in MIME format. --------------010004070607090607090506 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > On 09/04/2012 11:58 PM, Linda A. Walsh wrote: > >> I'm not talking for interactive use... I'm talking for use in a script >> that might run on systems that are not mine -- so I can't rely on shell settings. >> > > Yes you can. Just start the script with "#!/bin/sh", as usual. > When invoked that way, Bash and other shells are POSIX-compliant > in this area. > To what level of posix... if they are compliant to the original level then they might have the original behavior that allowed rm -r . to work. if they are the 2003 version, then a different way, .. bleh. I overly worry about things that don't occur, but get caught by things I didn't worry enough about. So it doesn't really matter. I just preferred simplicity to the ever changing posix. --------------010004070607090607090506 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q85Ep6lD729920 Paul Eggert wrote:
On 09/04/2012 11:58 PM, Linda A. Walsh wrote:
  
   I'm not talking for interactive use... I'm talking =
for use in a script
that might run on systems that are not mine -- so I can't rely on shell s=
ettings.
    

Yes you can.  Just start the script with "#!/bin/sh", as usual.
When invoked that way, Bash and other shells are POSIX-compliant
in this area.
  

To what level of posix... if they are compliant to the original level
then they might have the original behavior that allowed rm -r . to work.<= br>
if they are the 2003 version, then a different way, .. bleh.

I overly worry about things that don't occur, but get caught
by things I didn't worry enough about.=C2=A0=C2=A0 So it doesn't really matter.=C2=A0 I just preferred simplicity to the ever changing
posix.


--------------010004070607090607090506-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 10:51:43 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 14:51:44 +0000 Received: from localhost ([127.0.0.1]:40492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9GxD-0001eO-Ek for submit@debbugs.gnu.org; Wed, 05 Sep 2012 10:51:43 -0400 Received: from mx.meyering.net ([88.168.87.75]:42803) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Gx9-0001eD-Nn for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 10:51:41 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 4E7D3604E4; Wed, 5 Sep 2012 16:51:29 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <877gsac5h4.fsf@rho.meyering.net> (Jim Meyering's message of "Tue, 04 Sep 2012 14:55:35 +0200") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> Date: Wed, 05 Sep 2012 16:51:29 +0200 Message-ID: <87zk545xqm.fsf@rho.meyering.net> Lines: 104 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: ... > With the following patch, I see new behavior. > It's an improvement, but we're still not there: > > $ mkdir -p d/e/f; ln -s d s; rm -r s/ > rm: cannot remove 's/': Not a directory > [Exit 1] > $ find > . > ./s > ./d > > Notice how it did traverse s/ into d/, and removed d/e and d/e/f. > The only problem is that when it attempted to remove the command-line > specified "s/", unlinkat (AT_FDCWD, "s/", AT_REMOVEDIR) failed: > > unlinkat(4, "d", 0) = 0 > unlinkat(5, "f", AT_REMOVEDIR) = 0 > unlinkat(4, "e", AT_REMOVEDIR) = 0 > unlinkat(AT_FDCWD, "s/", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) > rm: cannot remove 's/': Not a directory > +++ exited with 1 +++ > > Now, this looks like a problem with unlinkat. That's probably a problem with unlinkat, but does not explain what caused the invalid diagnostic. BTW, while it was easy for me to discover that this bug was introduced between 8.5 and 8.6, neither rm.c nor remove.c had significant changes in that delta. And bisecting would have been a chore, since bootstrapping those versions is, um... challenging. That made me want to make each package in the volatile tool chain (m4, autoconf, automake and maybe even bison, too) into a submodule of coreutils. Currently it's trivial to build coreutils from a tarball, but it's not at all easy to bootstrap from an arbitrary version in git. Anyway, I ended up comparing strace output from 8.5's rm to that of the rm from 8.6. Here's the key difference: -openat(AT_FDCWD, "s", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY) = 3 +openat(AT_FDCWD, "s", O_RDONLY|O_NOCTTY|O_NONBLOCK|O_DIRECTORY|O_NOFOLLOW) = -1 ELOOP (Too many levels of symbolic links) ... unlinkat(AT_FDCWD, "s", AT_REMOVEDIR) = -1 ENOTDIR (Not a directory) The directory-opening code in gnulib's fts.c, which rm uses for recursive traversal, was fixed to avoid a race condition: commit 0971365ee6f6638cbeec77db08fbdfe5f3bab53d Author: Paul Eggert Date: Mon Sep 13 12:38:41 2010 -0700 fts: use O_NOFOLLOW to avoid race condition when opening a directory * lib/fts.c (opendirat): New arg extra_flags. (__opendir2): Use it to avoid following symlinks when opening a directory, if symlinks are not supposed to be followed. See . That was clearly a good change. What it did however, was to trigger a problem in remove.c, making it print this bogus diagnostic: rm: cannot remove 's': Too many levels of symbolic links Here's the bad code: /* When failing to rmdir an unreadable directory, the typical errno value is EISDIR, but that is not as useful to the user as the errno value from the failed open (probably EPERM). Use the earlier, more descriptive errno value. */ if (ent->fts_info == FTS_DNR) errno = ent->fts_errno; error (0, errno, _("cannot remove %s"), quote (ent->fts_path)); The fts change affected this code by making the "if" condition true. Before, the openat succeeded. Now, it fails with ELOOP. By telling openat not to follow symlinks, we've made fts set ->fts_info to FTS_DNR (unreadable directory), and that made remove.c use the prior errno value (the bogus ELOOP). While not necessary to fix the problem at hand, since I made it so the trailing slash is preserved down to the openat syscall, this additional change might avoid a similar problem down the road: - /* When failing to rmdir an unreadable directory, the typical - errno value is EISDIR, but that is not as useful to the user - as the errno value from the failed open (probably EPERM). - Use the earlier, more descriptive errno value. */ - if (ent->fts_info == FTS_DNR) + /* When failing to rmdir an unreadable directory, the typical errno value + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. + When that happens and the errno value from the failed open is EPERM + or EACCES, use the earlier, more descriptive errno value. */ + if (ent->fts_info == FTS_DNR + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) errno = ent->fts_errno; error (0, errno, _("cannot remove %s"), quote (ent->fts_path)); mark_ancestor_dirs (ent); I'll post this new pair of rm-related patches in a minute. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 10:56:43 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 14:56:44 +0000 Received: from localhost ([127.0.0.1]:40502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9H23-0001lJ-Cr for submit@debbugs.gnu.org; Wed, 05 Sep 2012 10:56:43 -0400 Received: from mx.meyering.net ([88.168.87.75]:42820) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9H20-0001lB-MQ for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 10:56:41 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 22ADE60525; Wed, 5 Sep 2012 16:56:33 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <87zk545xqm.fsf@rho.meyering.net> (Jim Meyering's message of "Wed, 05 Sep 2012 16:51:29 +0200") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <87zk545xqm.fsf@rho.meyering.net> Date: Wed, 05 Sep 2012 16:56:33 +0200 Message-ID: <87txvc5xi6.fsf@rho.meyering.net> Lines: 136 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: ... > I'll post this new pair of rm-related patches in a minute. Here's what I'm ready to push. Finally, I'm not adding a test for what happens when one tries to run rm -r s/ (with s being a symlink), since that is so system-specific. I suppose I could add test solely to ensure that if it fails, it does not fail with the ELOOP message, but that seems way too weak. >From 57dd06703cb89ba53d05af95c11e89a2ca51af5c Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 4 Sep 2012 14:40:11 +0200 Subject: [PATCH 1/2] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir These commands would evoke an invalid diagnostic: $ mkdir d && ln -s d s && env rm -r s/ rm: cannot remove 's': Too many levels of symbolic links remove.c was stripping trailing slashes from "s/" before passing the name to "rm". But a trailing slash may change the semantics, and thus should not be stripped. * src/remove.c (rm_fts): Do not strip trailing slashes. * tests/rm/v-slash.sh: Adapt to new expected output. * gnulib: Update to latest, for an improved fts.c that merely normalizes trailing slashes. Reported by Paul Eggert in discussion of http://bugs.gnu.org/12339 --- NEWS | 4 ++++ gnulib | 2 +- src/remove.c | 3 --- tests/rm/v-slash.sh | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index f3874fd..a848ffe 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ GNU coreutils NEWS -*- outline -*- than ignoring the -d option and failing with an 'Is a directory' error. [bug introduced in coreutils-8.19, with the addition of --dir (-d)] + rm -r S/ (where S is a symlink-to-directory) no longer gives the invalid + "Too many levels of symbolic links" diagnostic. + [bug introduced in coreutils-8.6] + ** Improvements stat and tail work better with ZFS. stat -f --format=%T now reports the diff --git a/gnulib b/gnulib index 68f693f..3a9002d 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 68f693ff1db33bf24695f0f42c62e7801966fd06 +Subproject commit 3a9002d3cc63da7110f133b1040d2d2b0aad8305 diff --git a/src/remove.c b/src/remove.c index 69faae6..847a5cc 100644 --- a/src/remove.c +++ b/src/remove.c @@ -433,9 +433,6 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x) /* Perform checks that can apply only for command-line arguments. */ if (ent->fts_level == FTS_ROOTLEVEL) { - if (strip_trailing_slashes (ent->fts_path)) - ent->fts_pathlen = strlen (ent->fts_path); - /* If the basename of a command line argument is "." or "..", diagnose it and do nothing more with that argument. */ if (dot_or_dotdot (last_component (ent->fts_accpath))) diff --git a/tests/rm/v-slash.sh b/tests/rm/v-slash.sh index 504f4ff..ec77bd0 100755 --- a/tests/rm/v-slash.sh +++ b/tests/rm/v-slash.sh @@ -26,7 +26,7 @@ touch a/x || framework_failure_ rm --verbose -r a/// > out || fail=1 cat <<\EOF > exp || fail=1 removed 'a/x' -removed directory: 'a' +removed directory: 'a/' EOF compare exp out || fail=1 -- 1.7.12.176.g3fc0e4c >From eda8c84778bc72192592b79724466946ca7def97 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 5 Sep 2012 16:48:50 +0200 Subject: [PATCH 2/2] rm: be more careful when using a replacement errno value * src/remove.c (excise): Tighten the test for when we defer to an old errno value: instead of relying solely on an FTS_DNR (unreadable directory) failure, also test current and replacement errno values. This change would also have solved the problem addressed by commit v8.19-106-g57dd067. For more info, see http://bugs.gnu.org/12339#113 --- gnulib | 2 +- src/remove.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gnulib b/gnulib index 3a9002d..68f693f 160000 --- a/gnulib +++ b/gnulib @@ -1 +1 @@ -Subproject commit 3a9002d3cc63da7110f133b1040d2d2b0aad8305 +Subproject commit 68f693ff1db33bf24695f0f42c62e7801966fd06 diff --git a/src/remove.c b/src/remove.c index 847a5cc..0c25462 100644 --- a/src/remove.c +++ b/src/remove.c @@ -392,11 +392,13 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) if (ignorable_missing (x, errno)) return RM_OK; - /* When failing to rmdir an unreadable directory, the typical - errno value is EISDIR, but that is not as useful to the user - as the errno value from the failed open (probably EPERM). - Use the earlier, more descriptive errno value. */ - if (ent->fts_info == FTS_DNR) + /* When failing to rmdir an unreadable directory, the typical errno value + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. + When that happens and the errno value from the failed open is EPERM + or EACCES, use the earlier, more descriptive errno value. */ + if (ent->fts_info == FTS_DNR + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) errno = ent->fts_errno; error (0, errno, _("cannot remove %s"), quote (ent->fts_path)); mark_ancestor_dirs (ent); -- 1.7.12.176.g3fc0e4c From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 11:11:15 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 15:11:15 +0000 Received: from localhost ([127.0.0.1]:40532 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HG6-00026M-IM for submit@debbugs.gnu.org; Wed, 05 Sep 2012 11:11:14 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:47618) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HG4-00026F-QD for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 11:11:13 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 1F3F6A60035; Wed, 5 Sep 2012 08:11:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qdIX5rPlmrPq; Wed, 5 Sep 2012 08:11:01 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id B0D76A60034; Wed, 5 Sep 2012 08:11:01 -0700 (PDT) Message-ID: <50476B85.2050102@cs.ucla.edu> Date: Wed, 05 Sep 2012 08:11:01 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <87zk545xqm.fsf@rho.meyering.net> <87txvc5xi6.fsf@rho.meyering.net> In-Reply-To: <87txvc5xi6.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/05/2012 07:56 AM, Jim Meyering wrote: > + /* When failing to rmdir an unreadable directory, the typical errno value > + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. > + When that happens and the errno value from the failed open is EPERM > + or EACCES, use the earlier, more descriptive errno value. */ > + if (ent->fts_info == FTS_DNR > + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) > + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) Thanks for doing all that. I did notice that the code mentions ENOTEMPTY but the comment doesn't -- is that intentional? From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 11:13:30 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 15:13:30 +0000 Received: from localhost ([127.0.0.1]:40537 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HIH-00029R-5J for submit@debbugs.gnu.org; Wed, 05 Sep 2012 11:13:30 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:47769) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HIF-00029K-KM for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 11:13:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 771FDA60036; Wed, 5 Sep 2012 08:13:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GUfj6iGzY7qq; Wed, 5 Sep 2012 08:13:20 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 18121A60034; Wed, 5 Sep 2012 08:13:20 -0700 (PDT) Message-ID: <50476C10.7030104@cs.ucla.edu> Date: Wed, 05 Sep 2012 08:13:20 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "Linda A. Walsh" Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> <5046F81E.5000806@tlinx.org> <50476303.70505@cs.ucla.edu> <504766DB.4050606@tlinx.org> In-Reply-To: <504766DB.4050606@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/05/2012 07:51 AM, Linda A. Walsh wrote: >> Just start the script with "#!/bin/sh", as usual. >> When invoked that way, Bash and other shells are POSIX-compliant >> in this area. > To what level of posix... To all the levels that are relevant for this discussion. In practice, people use "#!/bin/sh" and it works pretty well to avoid compatibility issues like this. It's not perfect for all POSIX issues, but you were asking for a solution to a particular problem, and this should solve your problem. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 11:18:37 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 15:18:37 +0000 Received: from localhost ([127.0.0.1]:40543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HNE-0002Gn-La for submit@debbugs.gnu.org; Wed, 05 Sep 2012 11:18:37 -0400 Received: from mx.meyering.net ([88.168.87.75]:42887) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9HNB-0002Ga-W6 for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 11:18:34 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 5ADA8601E5; Wed, 5 Sep 2012 17:18:21 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <50476B85.2050102@cs.ucla.edu> (Paul Eggert's message of "Wed, 05 Sep 2012 08:11:01 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <87zk545xqm.fsf@rho.meyering.net> <87txvc5xi6.fsf@rho.meyering.net> <50476B85.2050102@cs.ucla.edu> Date: Wed, 05 Sep 2012 17:18:21 +0200 Message-ID: <87oblk5whu.fsf@rho.meyering.net> Lines: 34 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Paul Eggert wrote: > On 09/05/2012 07:56 AM, Jim Meyering wrote: >> + /* When failing to rmdir an unreadable directory, the typical errno value >> + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. >> + When that happens and the errno value from the failed open is EPERM >> + or EACCES, use the earlier, more descriptive errno value. */ >> + if (ent->fts_info == FTS_DNR >> + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) >> + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) > > Thanks for doing all that. I did notice that the code mentions > ENOTEMPTY but the comment doesn't -- is that intentional? Yes. I considered whether to remove explicit mention of those errno values in the comment for precisely that reason, but didn't bother. Good point. I've relaxed the comment wording enough to permit other explicit E* names: diff --git a/src/remove.c b/src/remove.c index 0c25462..a141718 100644 --- a/src/remove.c +++ b/src/remove.c @@ -392,8 +392,8 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) if (ignorable_missing (x, errno)) return RM_OK; - /* When failing to rmdir an unreadable directory, the typical errno value - is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. + /* When failing to rmdir an unreadable directory, we see errno values + like EISDIR or ENOTDIR, but they would be meaningless in a diagnostic. When that happens and the errno value from the failed open is EPERM or EACCES, use the earlier, more descriptive errno value. */ if (ent->fts_info == FTS_DNR From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 16:22:21 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 20:22:21 +0000 Received: from localhost ([127.0.0.1]:41239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9M7A-0004UG-R8 for submit@debbugs.gnu.org; Wed, 05 Sep 2012 16:22:21 -0400 Received: from mx.meyering.net ([88.168.87.75]:43716) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9M78-0004U0-ST for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 16:22:20 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id C898C601E5; Wed, 5 Sep 2012 22:22:07 +0200 (CEST) From: Jim Meyering To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <87oblk5whu.fsf@rho.meyering.net> (Jim Meyering's message of "Wed, 05 Sep 2012 17:18:21 +0200") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <87zk545xqm.fsf@rho.meyering.net> <87txvc5xi6.fsf@rho.meyering.net> <50476B85.2050102@cs.ucla.edu> <87oblk5whu.fsf@rho.meyering.net> Date: Wed, 05 Sep 2012 22:22:07 +0200 Message-ID: <87oblk43v4.fsf@rho.meyering.net> Lines: 41 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Paul Eggert wrote: > >> On 09/05/2012 07:56 AM, Jim Meyering wrote: >>> + /* When failing to rmdir an unreadable directory, the typical errno value >>> + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. >>> + When that happens and the errno value from the failed open is EPERM >>> + or EACCES, use the earlier, more descriptive errno value. */ >>> + if (ent->fts_info == FTS_DNR >>> + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) >>> + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) >> >> Thanks for doing all that. I did notice that the code mentions >> ENOTEMPTY but the comment doesn't -- is that intentional? > > Yes. I considered whether to remove explicit mention of those errno > values in the comment for precisely that reason, but didn't bother. > Good point. I've relaxed the comment wording enough to permit other > explicit E* names: > > diff --git a/src/remove.c b/src/remove.c > index 0c25462..a141718 100644 > --- a/src/remove.c > +++ b/src/remove.c > @@ -392,8 +392,8 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) > if (ignorable_missing (x, errno)) > return RM_OK; > > - /* When failing to rmdir an unreadable directory, the typical errno value > - is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. > + /* When failing to rmdir an unreadable directory, we see errno values > + like EISDIR or ENOTDIR, but they would be meaningless in a diagnostic. > When that happens and the errno value from the failed open is EPERM > or EACCES, use the earlier, more descriptive errno value. */ > if (ent->fts_info == FTS_DNR I've pushed the result: http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=ccbd3f3b290cb1bb http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=57dd06703cb89ba5 From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 17:06:17 2012 Received: (at 12339) by debbugs.gnu.org; 5 Sep 2012 21:06:17 +0000 Received: from localhost ([127.0.0.1]:41310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Mnh-0005dp-F4 for submit@debbugs.gnu.org; Wed, 05 Sep 2012 17:06:17 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:51503 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Mnf-0005dg-69 for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 17:06:16 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q85L62EN808697; Wed, 5 Sep 2012 14:06:04 -0700 Message-ID: <5047BEBA.6090701@tlinx.org> Date: Wed, 05 Sep 2012 14:06:02 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <87zk545xqm.fsf@rho.meyering.net> <87txvc5xi6.fsf@rho.meyering.net> <50476B85.2050102@cs.ucla.edu> <87oblk5whu.fsf@rho.meyering.net> In-Reply-To: <87oblk5whu.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Thanks for the efforts at cleaning things up...it's appreciated even if it's not exactly what I might want...just wanted to emphasize that your I appreciate the work you are doing!.. I just don't always appreciate the 'posixifing' of linux's default behavior...but then I like powerful interface that allow me to shoot myself in the foot if I really want to! ;-) Jim Meyering wrote: > Paul Eggert wrote: > >> On 09/05/2012 07:56 AM, Jim Meyering wrote: >>> + /* When failing to rmdir an unreadable directory, the typical errno value >>> + is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. >>> + When that happens and the errno value from the failed open is EPERM >>> + or EACCES, use the earlier, more descriptive errno value. */ >>> + if (ent->fts_info == FTS_DNR >>> + && (errno == ENOTEMPTY || errno == EISDIR || errno == ENOTDIR) >>> + && (ent->fts_errno == EPERM || ent->fts_errno == EACCES)) >> Thanks for doing all that. I did notice that the code mentions >> ENOTEMPTY but the comment doesn't -- is that intentional? > > Yes. I considered whether to remove explicit mention of those errno > values in the comment for precisely that reason, but didn't bother. > Good point. I've relaxed the comment wording enough to permit other > explicit E* names: > > diff --git a/src/remove.c b/src/remove.c > index 0c25462..a141718 100644 > --- a/src/remove.c > +++ b/src/remove.c > @@ -392,8 +392,8 @@ excise (FTS *fts, FTSENT *ent, struct rm_options const *x, bool is_dir) > if (ignorable_missing (x, errno)) > return RM_OK; > > - /* When failing to rmdir an unreadable directory, the typical errno value > - is EISDIR or ENOTDIR, but that would be meaningless in a diagnostic. > + /* When failing to rmdir an unreadable directory, we see errno values > + like EISDIR or ENOTDIR, but they would be meaningless in a diagnostic. > When that happens and the errno value from the failed open is EPERM > or EACCES, use the earlier, more descriptive errno value. */ > if (ent->fts_info == FTS_DNR From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 21:17:11 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 01:17:11 +0000 Received: from localhost ([127.0.0.1]:41629 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9QiU-0002sR-Fe for submit@debbugs.gnu.org; Wed, 05 Sep 2012 21:17:11 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:59603 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9QiR-0002sG-6X for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 21:17:09 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q861Gqml859801; Wed, 5 Sep 2012 18:16:54 -0700 Message-ID: <5047F984.9040301@tlinx.org> Date: Wed, 05 Sep 2012 18:16:52 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> Subject: Re: bug#12339: [PATCH] rm: avoid bogus diagnostic for a slash-decorated symlink-to-dir References: <5043FA91.9070703@tlinx.org> <50463E62.2010101@tlinx.org> <50464000.8000603@cs.ucla.edu> <50468D11.9030607@tlinx.org> <5046A18E.6030808@cs.ucla.edu> <5046B128.8010409@tlinx.org> <5046F058.6020005@cs.ucla.edu> <5046F81E.5000806@tlinx.org> <50476303.70505@cs.ucla.edu> <504766DB.4050606@tlinx.org> <50476C10.7030104@cs.ucla.edu> In-Reply-To: <50476C10.7030104@cs.ucla.edu> Content-Type: multipart/alternative; boundary="------------020907070204040306010806" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is a multi-part message in MIME format. --------------020907070204040306010806 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Paul Eggert wrote: > On 09/05/2012 07:51 AM, Linda A. Walsh wrote: > >>> Just start the script with "#!/bin/sh", as usual. >>> When invoked that way, Bash and other shells are POSIX-compliant >>> in this area. >>> >> To what level of posix... >> > To all the levels that are relevant for this discussion. > > In practice, people use "#!/bin/sh" and it works pretty well > to avoid compatibility issues like this. It's not perfect > for all POSIX issues, but you were asking for a solution to > a particular problem, and this should solve your problem. > ----- Now I remember how I got here in the first place... It was because of bash moving to the POSIX 2003 standard and breaking many things I'd come to rely on, that I eventually realized that it was unsuitable to rely on for programming. I had written a logical volume snapshot generator and manager in about ~1500 lines of shell script across multiple files -- mostly as a proof of concept -- but also because it seemed simple and grew as I realized it was 90% error condition handling. Bash got very unreliable in handling error conditions via "-e" w/the new POSIX standard -- can't return non zero from a function (so no more mathematical functions), can't return non-zero from a calc (()) or let statement -- both of which now trigger error exits under "-e" due to POSIX More stuff happened, I decided to throw it away and rewrite in perl. I'm still wanting to call rm -fr without wild cards to remove everything in a directory. One would think the "rm" utility which is *designed* to remove files recursively, would do the task and NOT need the shell to do it's job. My perl program has tried to call rm -fr . and *, neither of which work. if rm can't remove all the files in a dir by itself -- I assert it is failing it's job as an 'rm' program. Removing files is it's sole job in life... it can remove singles and directories... using rm -fr ./. or dir/. or . were all ways of removing all contents under their targets without removing the directory. That feature is now gone. So I'd like to request it be added when not operating under POSIX_CORRECTLY. It's the right thing to do for the command line. We don't have so many clueless dweebs in a tty window -- most want point and click. I know I don't want to call bash as a helper for rm -- as I know with BASH_ENV, and such, it can very easily be running alot of overhead code besides the simple rm function I wanted to do. I think on many systems /bin/sh is a link to ash or dash, and no telling how they will act/perform -- I don't want an extra dependency. So should I start looking to write a patch for rm and possibly fork it? Just realizing that I'm where I'm at today because of bash going POSIX has left me pretty cold. --------------020907070204040306010806 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q861Gqml859801 Paul Eggert wrote:
On 09/05/2012 07:51 AM, Linda A. Walsh wrote:
  
Just start the script with "#!/bin/sh", as usual.
When invoked that way, Bash and other shells are POSIX-compliant
in this area.
      
To what level of posix...
    
To all the levels that are relevant for this disc=
ussion.

In practice, people use "#!/bin/sh" and it works pretty well
to avoid compatibility issues like this.  It's not perfect
for all POSIX issues, but you were asking for a solution to
a particular problem, and this should solve your problem.
  
-----
=C2=A0=C2=A0=C2=A0 Now I remember how I got here in the first place...
It was because of bash moving to the POSIX 2003 standard and breaking many things I'd come to rely on, that I eventually realized that it was unsuitable to rely on for programming.=C2=A0 I had written a logical volu= me
snapshot generator and manager in about ~1500 lines of shell script
across multiple files=C2=A0 -- mostly as a proof of concept -- but also because
it seemed simple and grew as I realized it was 90% error condition handling.

Bash got very unreliable in handling error conditions via "-e" w/the new<= br> POSIX standard -- can't return non zero from a function (so no more mathematical
functions), can't return non-zero from a calc (()) or let statement -- both
of which now trigger error exits under "-e" due to POSIX

More stuff happened, I decided to throw it away and rewrite in perl.

I'm still wanting to call rm -fr without wild cards to remove everything in
a directory.

One would think the "rm" utility which is *designed* to remove files recursively, would do the task and NOT need the shell to do it's job.

My perl program has tried to call rm -fr . and *, neither of which work.<= br>
if rm can't remove all the files in a dir by itself -- I assert it is failing
it's job as an 'rm' program.=C2=A0 Removing files is it's sole job in lif= e...
it can remove singles and directories... using rm -fr ./. or dir/. or . were
all ways of removing all contents under their targets without removing the directory.


That feature is now gone.=C2=A0

So I'd like to request it be added when not operating under POSIX_CORRECTLY.

It's the right thing to do for the command line.=C2=A0 We don't have so m= any clueless
dweebs in a tty window -- most want point and click.

I know I don't want to call bash as a helper for rm -- as I know
with BASH_ENV, and such, it can very easily be running alot of overhead code
besides the simple rm function I wanted to do.=C2=A0

I think on many systems /bin/sh is a link to ash or dash, and no telling how
they will act/perform -- I don't want an extra dependency.

So should I start looking to write a patch for rm and possibly fork it?
Just realizing that I'm where I'm at today because of bash going POSIX has
left me pretty cold.


--------------020907070204040306010806-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 05 23:25:37 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 03:25:37 +0000 Received: from localhost ([127.0.0.1]:41728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Sin-0005oT-17 for submit@debbugs.gnu.org; Wed, 05 Sep 2012 23:25:37 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:35987 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9Sik-0005oL-P7 for 12339@debbugs.gnu.org; Wed, 05 Sep 2012 23:25:35 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q863PEQU907101; Wed, 5 Sep 2012 20:25:16 -0700 Message-ID: <5048179A.1010005@tlinx.org> Date: Wed, 05 Sep 2012 20:25:14 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> In-Reply-To: <504620B5.2040406@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This doesn't check POSIX_CORRECTLY, but it does fix the reported problem rm -fr in . removes all files and leaves the dir: Ishtar:/tmp/ttt> touch one two three Ishtar:/tmp/ttt> cd .. Ishtar:/tmp> rm -fr ttt/. Ishtar:/tmp> ll ttt total 0 --- Also works cd'd into the dir and doing an "rm -fr ." I'll be happy to put in the check for POSIX_CORRECTLY if you are amenable... Note.. am not claiming this is the most efficient way to do it, but it seemed to be the least impact on code I was new to. Ishtar:packages/sources/coreutils-8.14> cat coreutils-8.14.remove.c.diff --- src/remove.c 2011-10-10 00:56:46.000000000 -0700 +++ src/remove.c 2012-09-05 18:23:58.449319142 -0700 @@ -446,6 +446,20 @@ return RM_ERROR; } + +static inline bool +dotdot (char const *file_name) +{ + if (file_name[0] == '.' && file_name[1]) + { + char sep = file_name[(file_name[1] == '.') + 1]; + return (! sep || ISSLASH (sep)); + } + else + return false; +} + + /* This function is called once for every file system object that fts encounters. fts performs a depth-first traversal. A directory is usually processed twice, first with fts_info == FTS_D, @@ -476,7 +490,7 @@ /* If the basename of a command line argument is "." or "..", diagnose it and do nothing more with that argument. */ - if (dot_or_dotdot (last_component (ent->fts_accpath))) + if (dotdot (last_component (ent->fts_accpath))) { error (0, 0, _("cannot remove directory: %s"), quote (ent->fts_path)); From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 02:56:35 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 06:56:35 +0000 Received: from localhost ([127.0.0.1]:41878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9W0x-00027p-9Z for submit@debbugs.gnu.org; Thu, 06 Sep 2012 02:56:35 -0400 Received: from mx.meyering.net ([88.168.87.75]:45214) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9W0t-00027i-Vt for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 02:56:32 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id B0CD860115; Thu, 6 Sep 2012 08:56:20 +0200 (CEST) From: Jim Meyering To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <5048179A.1010005@tlinx.org> (Linda Walsh's message of "Wed, 05 Sep 2012 20:25:14 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> Date: Thu, 06 Sep 2012 08:56:20 +0200 Message-ID: <87fw6v3ai3.fsf@rho.meyering.net> Lines: 58 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Linda Walsh wrote: > This doesn't check POSIX_CORRECTLY, but it does fix the reported problem > > rm -fr in . removes all files and leaves the dir: > > Ishtar:/tmp/ttt> touch one two three > Ishtar:/tmp/ttt> cd .. > Ishtar:/tmp> rm -fr ttt/. > Ishtar:/tmp> ll ttt > total 0 > > --- > Also works cd'd into the dir and doing an "rm -fr ." > > I'll be happy to put in the check for POSIX_CORRECTLY if you are amenable... > Note.. am not claiming this is the most efficient way to do it, but it > seemed to be the least impact on code I was new to. > > Ishtar:packages/sources/coreutils-8.14> cat coreutils-8.14.remove.c.diff > --- src/remove.c 2011-10-10 00:56:46.000000000 -0700 > +++ src/remove.c 2012-09-05 18:23:58.449319142 -0700 > @@ -446,6 +446,20 @@ > return RM_ERROR; > } > > + > +static inline bool > +dotdot (char const *file_name) > +{ > + if (file_name[0] == '.' && file_name[1]) > + { > + char sep = file_name[(file_name[1] == '.') + 1]; > + return (! sep || ISSLASH (sep)); > + } > + else > + return false; > +} > + > + > /* This function is called once for every file system object that fts > encounters. fts performs a depth-first traversal. > A directory is usually processed twice, first with fts_info == FTS_D, > @@ -476,7 +490,7 @@ > > /* If the basename of a command line argument is "." or "..", > diagnose it and do nothing more with that argument. */ > - if (dot_or_dotdot (last_component (ent->fts_accpath))) > + if (dotdot (last_component (ent->fts_accpath))) > { > error (0, 0, _("cannot remove directory: %s"), > quote (ent->fts_path)); Thanks for the patch, but it would be pretty rotten for GNU rm to make it so "rm -rf ." deletes everything under ".", while all other vendor rm programs diagnose the POSIX-mandated error. People would curse us for making GNU rm remove their precious files when they accidentally ran that command. Even if that were done only when POSIX_CORRECTLY were not set, they would still be burned. Very few people ever set that envvar. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 06:56:46 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 10:56:46 +0000 Received: from localhost ([127.0.0.1]:42344 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9ZlO-0007it-4y for submit@debbugs.gnu.org; Thu, 06 Sep 2012 06:56:46 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:49935 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9ZlM-0007il-0a for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 06:56:45 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q86AuIaS972318; Thu, 6 Sep 2012 03:56:21 -0700 Message-ID: <50488153.506@tlinx.org> Date: Thu, 06 Sep 2012 03:56:19 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> In-Reply-To: <87fw6v3ai3.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Thanks for the patch, but it would be pretty rotten for GNU rm to make > it so "rm -rf ." deletes everything under ".", while all other vendor > rm programs diagnose the POSIX-mandated error. People would curse us > for making GNU rm remove their precious files when they accidentally ran > that command. --- Just like people who ran "rm -fr * in /" and didn't get their POSIX mandated behavior, would curse you? You are playing Mommy, to people and not allowing them to do what they are asking the computer to do. You disabling rm's ability to function. There is no way for it to remove files in it's directory and not the current directory without this patch. It cripples the program. To do the same job requires use of auxiliary programs. ** Users would already be cursing those who deliberately crippled ** usability in the name of compatibility. Unix didn't have Windows-ish mentality on the command line... but wouldn't unix users curse those who brought such to the unix command line? "There needs to be someone willing to to step up for user freedom, and Gnu used to be that... but it seems they are becoming corrupt like every big organization" -- is that what you wish to become Gnu's epitaph? Users who saw Gnu as a freedom supporting symbol will see this as "selling-out" functionality in order to become respectable. You are claim users would curse not being able to get an error message for something they deliberately type in. Whereas I describe users who curse due to you removing functionality. You really would rather support those who are looking for error messages over those looking for functionality? I would question the wisdom of taking that approach, especially when you've been clearly called on it. GNU needs to be clear their priorities -- maintaining software freedom, or bowing down to corporate powers... POSIX isn't a user group -- it's an enforcement arm of a Corporate Entity that seeks to create a proprietary vision (it is owned by them -- Unix, POSIX, The OpenGroup... are all owned by the corporate entity who holds those as assets -- (see the legal pages at their website: like http://www.opengroup.org/content/legal-frequently-asked-questions). Since when does Gnu put corporate interests before users? From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 07:14:11 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 11:14:11 +0000 Received: from localhost ([127.0.0.1]:42361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9a2F-00087b-4g for submit@debbugs.gnu.org; Thu, 06 Sep 2012 07:14:11 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:56503) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9a2B-00087S-Jz for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 07:14:08 -0400 Received: from oxbaltgw11.schlund.de (oxbaltgw11.schlund.de [172.19.246.17]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0LeQDB-1Tv4OD40Bp-00q9jp; Thu, 06 Sep 2012 13:13:45 +0200 Date: Thu, 6 Sep 2012 13:13:44 +0200 (CEST) From: Bernhard Voelker To: Linda Walsh , Jim Meyering Message-ID: <1121384454.1133069.1346930024883.JavaMail.open-xchange@email.1und1.de> Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v- X-Provags-ID: V02:K0:Qj+x8A4t3RW0AzbDmGmILahijAcla7e72y2ZXrGoaEM mWTWA5DRJiASGPR6yTb4vc4/qqR2NbfmPwrnag2tZZxSwDSNlV MY4F9rPQgGz8wRGPf3G5+7jxVeb44K24NqCPLy1hUtaHfUivbM wwLOi9qwUL+lPC+wGN6SvsrkBWOYTOMsfbdVZaCf6EAHDAvcJe f+r7FS76XikHZ+vD6VGfJE79yqIft5kFE3A/jQiFSOtfKqZCq9 UNwDBwfd184THfwX967epaZkr+wEQRgL56SQr7mmqQARV/ZBMF 1NLAreBXevBrkGu+Hr/qMJkC70Li5IyHRO40YxcLwANUpnxb3v wWRZD/DStEzxVOaEgtqrf4nomDv8uDZwLLx4SRUHfw1/BWtnNU XRwA9nKNim6VLqjVcQSsuCLNvScaajU/zDkgDjwZs2xUVGaN/3 fX7Lh X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Bernhard Voelker List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On September 6, 2012 at 12:56 PM Linda Walsh wrote: > Jim Meyering wrote: > > Thanks for the patch, but it would be pretty rotten for GNU rm to make > > it so "rm -rf ." deletes everything under ".", while all other vendor > > rm programs diagnose the POSIX-mandated error. People would curse us > > for making GNU rm remove their precious files when they accidentally ran > > that command. > --- > > Just like people who ran "rm -fr * in /" and didn't get their POSIX > mandated behavior, would curse you? > > You are playing Mommy, to people and not allowing them to do what > they are asking the computer to do. > > [... and ~40 lines re. Jim, GNU, POSIX, the universe ...] Dear Linda, why don't you stick to the point? You provided a patch which changes the *default behaviour* of rm, and Jim told you that we can't/shouldn't do this. What you want was an option to delete the content of a directory. So why discussing all the world and his brother instead of providing a new patch introducing such a new option (e.g. --only-dir-content, there should be a better name)? Generalizations like that don't help here, IMHO. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 07:16:20 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 11:16:20 +0000 Received: from localhost ([127.0.0.1]:42368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9a4J-0008Az-QX for submit@debbugs.gnu.org; Thu, 06 Sep 2012 07:16:20 -0400 Received: from mx.meyering.net ([88.168.87.75]:45895) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9a4H-0008Aq-W9 for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 07:16:18 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 913ED603A2; Thu, 6 Sep 2012 13:16:04 +0200 (CEST) From: Jim Meyering To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <50488153.506@tlinx.org> (Linda Walsh's message of "Thu, 06 Sep 2012 03:56:19 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> Date: Thu, 06 Sep 2012 13:16:04 +0200 Message-ID: <87obljz9jf.fsf@rho.meyering.net> Lines: 17 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Linda Walsh wrote: ... > GNU needs to be clear their priorities -- maintaining software > freedom, or bowing down to corporate powers... POSIX isn't While POSIX is in general a very good baseline, no one here conforms blindly. If POSIX is wrong, we'll lobby to change it, or, when that fails, maybe relegate the undesirable required behavior to when POSIXLY_CORRECT is set, or even simply ignore it. In fact, over the years, I have deliberately made a few GNU tools contravene some aspects of POSIX-specified behavior that I felt were counterproductive. We try to make the tools as useful as possible, sometimes adding features when we deem them worthwhile. However, we are very much against changing the *default* behavior (behavior that has been that way for over 20 years and that is compatible with all other vendor-supplied rm programs) without a very good reason. From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 12:42:32 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 16:42:32 +0000 Received: from localhost ([127.0.0.1]:44443 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9f9z-0000uz-Rl for submit@debbugs.gnu.org; Thu, 06 Sep 2012 12:42:32 -0400 Received: from joseki.proulx.com ([216.17.153.58]:57018) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9f9x-0000us-GF for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 12:42:30 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id E1D0A21250; Thu, 6 Sep 2012 10:42:15 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 97B522DCC2; Thu, 6 Sep 2012 10:42:15 -0600 (MDT) Date: Thu, 6 Sep 2012 10:42:15 -0600 From: Bob Proulx To: Linda Walsh , 12339@debbugs.gnu.org Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. Message-ID: <20120906164215.GA19913@hysteria.proulx.com> References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87obljz9jf.fsf@rho.meyering.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Linda Walsh wrote: > ... > > GNU needs to be clear their priorities -- maintaining software > > freedom, or bowing down to corporate powers... POSIX isn't > > While POSIX is in general a very good baseline, no one here conforms > blindly. If POSIX is wrong, we'll lobby to change it, or, when > that fails, maybe relegate the undesirable required behavior to when > POSIXLY_CORRECT is set, or even simply ignore it. In fact, over the > years, I have deliberately made a few GNU tools contravene some aspects > of POSIX-specified behavior that I felt were counterproductive. > > We try to make the tools as useful as possible, sometimes adding features > when we deem them worthwhile. However, we are very much against changing > the *default* behavior (behavior that has been that way for over 20 > years and that is compatible with all other vendor-supplied rm programs) > without a very good reason. Because I originally voted that this felt like a bug I wanted to state that after determining that this has already been legacy system historical practice for a very long time that I wouldn't change it now. Portability of applications is more important. This isn't a feature that could be working in a script for someone. It isn't something that was recently removed that would cause a script to break. A script will run now with the same behavior across multiple different types of systems. I think we should leave things unchanged. Bob From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 06 13:41:00 2012 Received: (at 12339) by debbugs.gnu.org; 6 Sep 2012 17:41:00 +0000 Received: from localhost ([127.0.0.1]:44603 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9g4a-0002hl-5g for submit@debbugs.gnu.org; Thu, 06 Sep 2012 13:41:00 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:33216 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9g4Y-0002he-1E for 12339@debbugs.gnu.org; Thu, 06 Sep 2012 13:40:59 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q86HecpX083098; Thu, 6 Sep 2012 10:40:40 -0700 Message-ID: <5048E016.90504@tlinx.org> Date: Thu, 06 Sep 2012 10:40:38 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <1121384454.1133069.1346930024883.JavaMail.open-xchange@email.1und1.de> In-Reply-To: <1121384454.1133069.1346930024883.JavaMail.open-xchange@email.1und1.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q86HecpX083098 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Bernhard Voelker wrote: >=20 >=20 > On September 6, 2012 at 12:56 PM Linda Walsh wrot= e: >=20 >> Jim Meyering wrote: >>> Thanks for the patch, but it would be pretty rotten for GNU rm to mak= e >>> it so "rm -rf ." deletes everything under ".", while all other vendor >>> rm programs diagnose the POSIX-mandated error. People would curse us >>> for making GNU rm remove their precious files when they accidentally = ran >>> that command. >> --- >> >> Just like people who ran "rm -fr * in /" and didn't get their POSIX >> mandated behavior, would curse you? >> >> You are playing Mommy, to people and not allowing them to do what >> they are asking the computer to do. >> >> [... and ~40 lines re. Jim, GNU, POSIX, the universe ...] >=20 > Dear Linda, >=20 > why don't you stick to the point? ---- I wasn't the one who raised the point of people cursing Gnu for removing their precious when they accidently or deliberat= ely tried to invoked rm in a way to generate a non-functional behavior. If we were going to talk about them cursing gnu, I thought I would fully put it in perspective. That's what that expos=C3=A9 was about. Note -- that it wasn't personally directly, and included listed facts for a stronger counterpoint to what, admittedly, was likely a light= ly given reason for not changing a default behavior. It was addressing that comment, alone. You want an on-point counter proposal: Might I suggest this as a rational counter proposal. If the user issues rm -r ., it issues a warning: "Do you really wish to remove all files under '.'"? That won't break compatible behavior. Only if the user chooses the non-default 'force' option "do what I say and shut up", which is not a default option", would it do the action I suggest. In any case, if POSIX_CORRECTLY is set, it will act as per POSIX require= ments. It is TELLING, and important to understand Jim's statement " Very few people ever set that envvar." Most people don't want strict P= OSIX compatbility -- for reasons exactly like this -- the POSIX isn't about=20 usability, it's about program portability. So for interactive use, it wouldn't be someth= ing most people would want to use. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 10:17:19 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 14:17:19 +0000 Received: from localhost ([127.0.0.1]:46696 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zN0-0006sh-Ny for submit@debbugs.gnu.org; Fri, 07 Sep 2012 10:17:18 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:45395 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zMx-0006sV-CA for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 10:17:16 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87EGfpW478047; Fri, 7 Sep 2012 07:16:43 -0700 Message-ID: <504A01C9.7030005@tlinx.org> Date: Fri, 07 Sep 2012 07:16:41 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> In-Reply-To: <87obljz9jf.fsf@rho.meyering.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Jim Meyering wrote: > Linda Walsh wrote: > ... >> GNU needs to be clear their priorities -- maintaining software >> freedom, or bowing down to corporate powers... POSIX isn't > > While POSIX is in general a very good baseline, no one here conforms > blindly. If POSIX is wrong, we'll lobby to change it, or, when > that fails, maybe relegate the undesirable required behavior to when > POSIXLY_CORRECT is set, or even simply ignore it. In fact, over the > years, I have deliberately made a few GNU tools contravene some aspects > of POSIX-specified behavior that I felt were counterproductive. > > We try to make the tools as useful as possible, sometimes adding features > when we deem them worthwhile. However, we are very much against changing > the *default* behavior (behavior that has been that way for over 20 > years and that is compatible with all other vendor-supplied rm programs) > without a very good reason. ---- So if I make it enabled with an ENV var set to RM_FILES_DEPTH_FIRST, to enable the behavior, then you'd have no problem accepting the patch? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 10:23:55 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 14:23:55 +0000 Received: from localhost ([127.0.0.1]:46704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zTO-00072B-GX for submit@debbugs.gnu.org; Fri, 07 Sep 2012 10:23:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34534) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zTI-00071y-Ad for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 10:23:53 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87ENKG9020836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 10:23:21 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q87ENKpp012654; Fri, 7 Sep 2012 10:23:20 -0400 Message-ID: <504A0357.6050806@redhat.com> Date: Fri, 07 Sep 2012 08:23:19 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> In-Reply-To: <504A01C9.7030005@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1CBD046385F82330AEBA7B15" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1CBD046385F82330AEBA7B15 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 08:16 AM, Linda Walsh wrote: >> >> We try to make the tools as useful as possible, sometimes adding featu= res >> when we deem them worthwhile. However, we are very much against chang= ing >> the *default* behavior (behavior that has been that way for over 20 >> years and that is compatible with all other vendor-supplied rm program= s) >> without a very good reason. >=20 > ---- > So if I make it enabled with an ENV var set to RM_FILES_DEPTH_FIRST= , > to enable > the behavior, then you'd have no problem accepting the patch? I personally detest new env-vars that change long-standing behavior, because you then have to audit EVERY SINGLE SCRIPT to ensure that its use is unimpacted if the new env-var is set. It must either be an existing env-var, or my personal preference of a new --long-option. But if you want to submit a patch so that 'rm -r --depth-first .' does what you want, I'm probably 60-40 in favor of including it. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1CBD046385F82330AEBA7B15 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSgNXAAoJEKeha0olJ0NqsPAH/RFltN9sxwRKoDhkCYRXXnVn Ybqzpr4ty+k2QLuUUjnT8eDvRwh2zndzigcZE4Uo06+UX2iPZHeU+B+9RJXVgtCA 44X66/SPx7tzGKOtwud6+jjVDSZboH0sROv9awdjG2fC+MzsO/Io/1Z3pBMvSJdE GoAbI/WVMQtAcbUum2lm6/aLlTaROGwUyv9mk2FKmCQCoTW0tYJzhmkdf/fZPBy+ v3I9JqslP3noUAqutIHXE4zKO/d3PBpdbPKm1HyQuh6ERm5FpilAlmqis1E9lm/M DeWh6usOmTUPxdEGcRdaMbKrSCnAAgFXtSOzMsiwYhjmI0onTN1If9Xwf/6U/iU= =4U/3 -----END PGP SIGNATURE----- --------------enig1CBD046385F82330AEBA7B15-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 10:31:39 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 14:31:39 +0000 Received: from localhost ([127.0.0.1]:46746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zas-00085k-D2 for submit@debbugs.gnu.org; Fri, 07 Sep 2012 10:31:39 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:45730 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zao-00085b-RC for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 10:31:37 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87EVAKi484305; Fri, 7 Sep 2012 07:31:12 -0700 Message-ID: <504A052E.50900@tlinx.org> Date: Fri, 07 Sep 2012 07:31:10 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> In-Reply-To: <504A0357.6050806@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: > I personally detest new env-vars that change long-standing behavior, > because you then have to audit EVERY SINGLE SCRIPT to ensure that its > use is unimpacted if the new env-var is set. It must either be an > existing env-var, or my personal preference of a new --long-option. But > if you want to submit a patch so that 'rm -r --depth-first .' does what > you want, I'm probably 60-40 in favor of including it. --- I wouldn't be opposed to adding it in addition, but I don't want the extra typing for what is the more common case for me, but given that the current behavior is to return an error -- and there is an expectation of being able to type in non-working commands just to see the error message -- imagine their surprise and how they would curse if you added an option that actually made that previously illegal action, work. Most of them who type in random wrong commands just to see error messages aren't smart enough to use environment variables. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 10:47:02 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 14:47:02 +0000 Received: from localhost ([127.0.0.1]:46766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zpl-0008Tb-LW for submit@debbugs.gnu.org; Fri, 07 Sep 2012 10:47:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42798) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zpi-0008TN-8c for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 10:47:00 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87EkaqR026443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 10:46:36 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q87EkYpa008293; Fri, 7 Sep 2012 10:46:35 -0400 Message-ID: <504A08C9.4030003@redhat.com> Date: Fri, 07 Sep 2012 08:46:33 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> <504A052E.50900@tlinx.org> In-Reply-To: <504A052E.50900@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig7C3166E68E9E16CA1B158E65" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig7C3166E68E9E16CA1B158E65 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 08:31 AM, Linda Walsh wrote: > I wouldn't be opposed to adding it in addition,=20 Adding what in addition to what? Adding a --long-option is fine. Adding an env-var is controversial. Stick to just one addition. > but I don't want the extra > typing for what is the more common case for me, Then set up a shell alias or a wrapper script that comes first in your $PATH. Then it is under your explicit control, while the default is still appropriate for everyone else. Just because the defaults don't match your expectations doesn't mean you can't change the behavior _on your system_ to avoid extra typing on your part. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig7C3166E68E9E16CA1B158E65 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSgjKAAoJEKeha0olJ0NqgQAH/Ru0kAj8IJeRELT7+EImmJvo av7N8HEXQ7eB68/qdV9VmxFg+jj15FY0JkRKJdHvybtdyXPMXXWR9/HD+oH4hoU7 aTA6ZjHEuoGMe4jdNOi2FE9jd8x1wWb72C33lejB3vbr7EBOMEnzI0AOMD94aocs +D8sx5GIRAaHDG6VD1koE3nwSf1tuU9627uoVc4mhj0klkCDKnyGvB5TqodWJt49 lX40qDxjDrXNBLoY4ebY7tofsmlrQAvHwvoWmZt0a1btPKy1nQZwCXwLAvoyYw6c ekTucjjY5rE52dgsPKTYkglHCc4qVKWRKFXXOY2MiRO7sx5XPJFqfx6CxLGrut0= =7/N6 -----END PGP SIGNATURE----- --------------enig7C3166E68E9E16CA1B158E65-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 10:55:21 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 14:55:21 +0000 Received: from localhost ([127.0.0.1]:46783 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zxo-0000ET-Gy for submit@debbugs.gnu.org; Fri, 07 Sep 2012 10:55:20 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:47031 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1T9zxl-0000EL-CH for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 10:55:18 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87Esuc7491290; Fri, 7 Sep 2012 07:54:58 -0700 Message-ID: <504A0AC0.3070601@tlinx.org> Date: Fri, 07 Sep 2012 07:54:56 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Bob Proulx Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> In-Reply-To: <20120906164215.GA19913@hysteria.proulx.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Bob Proulx wrote: > > Because I originally voted that this felt like a bug I wanted to state > that after determining that this has already been legacy system > historical practice for a very long time that I wouldn't change it > now. Portability of applications is more important. ---- Right now, the feature is unused, So hurting compatibility is not an issue - users can push for the feature on other systems as needed. It certainly isnt' a safety issue, since rm ** on a bouncy keyboard is alot easier to type than rm -fr *, and the former will remove all files under the current dir (just none of the directories) I suppose rm **;rmdir ** would work -- but but require SHELL. I think adding the case of rm -fr . or (dirname/.) to delete contents of the dir, but not the dir itself makes more sense and is safer than the easier to type rm ** > > This isn't a feature that could be working in a script for someone. > It isn't something that was recently removed that would cause a script > to break. A script will run now with the same behavior across > multiple different types of systems. I think we should leave things > unchanged. ---- It's only been recently that I've noticed rm -fr . not working and I can't figure out why since it hasn't been around for so long. Consider the parallel, if I want to make sure I copy the contents of a dir, I need to use cp dir/. dest/ If I use dir/ or dir, they both end up in dest (even with the "/"). That means without using ".", the contents are not addressable, so what is demanded by 'cp', is refused by 'rm'. That is not a consistent user interface and is symptomatic of poor design. Using "." to reference content of a dir is standard in other utils -- that it doesn't work in 'rm' goes counter to the idea of how rm works -- you have to remove contents before trying the current dir. It isn't logical to think that it would try the current dir before anything else -- as it goes completely contrary to how rm has to work. I say it's a design flaw and inconsistent with other programs. But if I can set an env var and have it work on my system, someone else can work to get the core utils to work consistently... From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 11:03:26 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 15:03:26 +0000 Received: from localhost ([127.0.0.1]:46814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA05d-0001Ie-JN for submit@debbugs.gnu.org; Fri, 07 Sep 2012 11:03:26 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:47161 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA05a-0001IW-9y for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 11:03:23 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87F2wUD492922; Fri, 7 Sep 2012 08:03:00 -0700 Message-ID: <504A0CA2.4040103@tlinx.org> Date: Fri, 07 Sep 2012 08:02:58 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> <504A052E.50900@tlinx.org> <504A08C9.4030003@redhat.com> In-Reply-To: <504A08C9.4030003@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: > > Then set up a shell alias or a wrapper script that comes first in your > $PATH. Then it is under your explicit control, while the default is > still appropriate for everyone else. > > Just because the defaults don't match your expectations doesn't mean you > can't change the behavior _on your system_ to avoid extra typing on your > part. --- Doesn't work for programs that need to call rm to remove all files in a dir. And I already have changed default behavior on MY systems. I already added the patch below -- that only does my behavior if the user isn't running in POSIXLY_CORRECT mode. Now it's certainly easier to set an env var 1 place to control script behavior than making changes in all the places... I'm just trying to get the env var in so I don't have to distribute a version of rm with my scripts that works. ----- --- src/remove.c 2011-10-10 00:56:46.000000000 -0700 +++ src/remove.c.new 2012-09-06 14:28:07.816810683 -0700 @@ -173,6 +173,35 @@ } } + +/* separate functions to check for next part of file name being dotdot or...*/ + +static inline bool +dotdot (char const *file_name) +{ + if (file_name[0] == '.' && file_name[1]) + { + char sep = file_name[(file_name[1] == '.') + 1]; + return (! sep || ISSLASH (sep)); + } + else + return false; +} + +/* dot */ + +static inline bool +dot (char const * file_name) +{ + if (file_name[0] == '.') + { + char sep = file_name[1]; + return (! sep || ISSLASH(sep)); + } + else + return false; +} + /* Prompt whether to remove FILENAME (ent->, if required via a combination of the options specified by X and/or file attributes. If the file may be removed, return RM_OK. If the user declines to remove the file, @@ -203,6 +232,7 @@ int dirent_type = is_dir ? DT_DIR : DT_UNKNOWN; int write_protected = 0; + int special_delete_content = 0; /* When nonzero, this indicates that we failed to remove a child entry, either because the user declined an interactive prompt, or due to @@ -222,7 +252,11 @@ wp_errno = errno; } - if (write_protected || x->interactive == RMI_ALWAYS) + if (!x->posix_correctly && dot(filename) && !x->force) + special_delete_content = 1; + + + if (write_protected || x->interactive == RMI_ALWAYS || special_delete_content) { if (0 <= write_protected && dirent_type == DT_UNKNOWN) { @@ -281,11 +315,16 @@ if (dirent_type == DT_DIR && mode == PA_DESCEND_INTO_DIR && !is_empty) - fprintf (stderr, - (write_protected - ? _("%s: descend into write-protected directory %s? ") - : _("%s: descend into directory %s? ")), - program_name, quoted_name); + { + char * action = special_delete_content + ? _("delete contents of") + : _("descend into"); + fprintf (stderr, + (write_protected + ? _("%s: %s write-protected directory %s? ") + : _("%s: %s directory %s? ")), + action, program_name, quoted_name); + } else { if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) @@ -476,7 +515,8 @@ /* If the basename of a command line argument is "." or "..", diagnose it and do nothing more with that argument. */ - if (dot_or_dotdot (last_component (ent->fts_accpath))) + if ( (x->posix_correctly ? dot_or_dotdot : dotdot) + (last_component (ent->fts_accpath))) { error (0, 0, _("cannot remove directory: %s"), quote (ent->fts_path)); --- src/remove.h 2011-07-28 03:38:27.000000000 -0700 +++ src/remove.h 2012-09-06 13:33:01.282362765 -0700 @@ -34,6 +34,14 @@ /* If true, ignore nonexistent files. */ bool ignore_missing_files; + /* true if force (-f) was specified indicating user knows what they + * are doing and don't want to questioned or see errors from command */ + bool force; + + /* true for users wanting strict posix compliance of more flexible, lax, + * or useful behaviors */ + bool posix_correctly; + /* If true, query the user about whether to remove each file. */ enum rm_interactive interactive; --- src/rm.c 2011-10-02 02:20:54.000000000 -0700 +++ src/rm.c 2012-09-06 13:33:04.132500554 -0700 @@ -206,6 +206,7 @@ bool preserve_root = true; struct rm_options x; bool prompt_once = false; + x.posix_correctly = (getenv ("POSIXLY_CORRECT") != NULL ); int c; initialize_main (&argc, &argv); @@ -222,10 +226,11 @@ { switch (c) { - case 'f': + case 'f': /* suppress warnings/errors */ x.interactive = RMI_NEVER; x.ignore_missing_files = true; prompt_once = false; + x.force = true; break; case 'i': From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 12:30:50 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 16:30:50 +0000 Received: from localhost ([127.0.0.1]:46925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA1SE-0003H0-0j for submit@debbugs.gnu.org; Fri, 07 Sep 2012 12:30:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13746) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA1SB-0003Gs-9z for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 12:30:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87GUR2u021304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 12:30:27 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q87GUPSY006842; Fri, 7 Sep 2012 12:30:26 -0400 Message-ID: <504A211C.9050303@redhat.com> Date: Fri, 07 Sep 2012 10:30:20 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> In-Reply-To: <504A0AC0.3070601@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig5046169A2C2310CE08ABA1B9" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig5046169A2C2310CE08ABA1B9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 08:54 AM, Linda Walsh wrote: >=20 > Using "." to reference content of a dir is standard in other utils -- t= hat > it doesn't work in 'rm' goes counter to the idea of how rm works -- you= > have > to remove contents before trying the current dir. It isn't logical to > think > that it would try the current dir before anything else -- as it goes > completely > contrary to how rm has to work. At the syscall level, unlink(".") is required to fail. To remove a directory, you must remove its proper name. You can use unlink("../child") on systems like Linux that let you remove a directory that is used as a process' current working directory (on systems like Windows where this action is forbidden, there's no way to remove the current working directory). Therefore, at the shell level, POSIX will let you do 'rm -r ../child'. If you think that POSIX should _also_ let you attempt 'rm -r .', then propose that as a defect report against POSIX, rather than griping here. >=20 > I say it's a design flaw and inconsistent with other programs. I would say that it is not a design flaw, but that it is consistent with the fact that the unlink(".") syscall is required to fail, and that it is consistent with other Unix implementations. We can agree to disagree on that point. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig5046169A2C2310CE08ABA1B9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSiEcAAoJEKeha0olJ0Nq6qgH/2hxi41RDlmY1pUoa4t6DakC ycvxbnvOyeWmBGmJsww0T0ezzsXkABcESu+Wk6M2UMeB6Ac/VevT2mBunoO9iiI1 8e7h1uO44xjFjEMKQZqTYoFfi8QqJaBYZwko/QcWmnnP2LR8M7w4zODO4Wzws1g4 WXh+TR+VlyGoTqRxlv3N3t7SMRvDW7dsA2oqdILW8sat6xc60GXcylsCKLwWGKZ9 om7OSCWj3OfcYI/pJ1+473wKx0Ewuo3gH8YpZmKXVkTpN0HWABbOWWXiZfwkuWTA bbkM9qombU88d1hgKYJ2mhR/zM61Ll4QOKrFk8yGu2DETOA4iAA77cEdRApb/iY= =0pht -----END PGP SIGNATURE----- --------------enig5046169A2C2310CE08ABA1B9-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 16:56:58 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 20:56:58 +0000 Received: from localhost ([127.0.0.1]:47237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA5bm-0001ok-3V for submit@debbugs.gnu.org; Fri, 07 Sep 2012 16:56:58 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:58242 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA5bj-0001oa-OE for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 16:56:57 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87KuXE4569088; Fri, 7 Sep 2012 13:56:35 -0700 Message-ID: <504A5F81.3030005@tlinx.org> Date: Fri, 07 Sep 2012 13:56:33 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> In-Reply-To: <504A211C.9050303@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: > On 09/07/2012 08:54 AM, Linda Walsh wrote: >> Using "." to reference content of a dir is standard in other utils -- that >> it doesn't work in 'rm' goes counter to the idea of how rm works -- you >> have >> to remove contents before trying the current dir. It isn't logical to >> think >> that it would try the current dir before anything else -- as it goes >> completely >> contrary to how rm has to work. > > At the syscall level, unlink(".") is required to fail. To remove a > directory, you must remove its proper name. You can use > unlink("../child") on systems like Linux that let you remove a directory > that is used as a process' current working directory (on systems like > Windows where this action is forbidden, there's no way to remove the > current working directory). Therefore, at the shell level, POSIX will > let you do 'rm -r ../child'. If you think that POSIX should _also_ let > you attempt 'rm -r .', then propose that as a defect report against > POSIX, rather than griping here. > >> I say it's a design flaw and inconsistent with other programs. > > I would say that it is not a design flaw, but that it is consistent with > the fact that the unlink(".") syscall is required to fail, and that it > is consistent with other Unix implementations. We can agree to disagree > on that point. Really, I didn't say rm -fr . should *delete* the current directory -- IT SHOULD FAIL -- you are 100% correct. But it is true that anyone who knows the smallest bit about unix knows that you have to empty the directory before deleting the directory, and, thus, "rm" _MUST_ do a depth first traversal. If it did and gave an error at the end: no issue. It's the special check BEFORE doing the work it would normally do, and failing BEFORE, it does it's NORMAL work -- the depth first deletion, that I am against. Griping against POSIX is like griping against the government. But very few people always go the speed limit and would regard a vehicle that is *unable* function normally, as faulty. So I am not disagreeing that it should fail, Please be clear about what I am asking. Also, I would *expect*, that rm -r . would at least, _ask_ you if you wanted to remove files under a directory that will be unable to be deleted. I am only asking for the behavior I describe to work without issuing an error when I do "rm -fr" I am specifically asking rm to forcefully remove what it can and remove and CONTINUE to delete what it can in spite of any errors it might encounter. Again, the fact that this fails defies normal logic with 'rm'. I don't believe that rm -fr . has failed for 20 years. I don't know when it changed, but it used to be that "rm" didn't have a special check for "." -- BECAUSE -- as you mention, an attempt to unlink "." will fail -- Using the "-f" suppresses any error message. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 17:20:45 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 21:20:45 +0000 Received: from localhost ([127.0.0.1]:47252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA5yn-0002MX-8z for submit@debbugs.gnu.org; Fri, 07 Sep 2012 17:20:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12988) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA5yj-0002MO-5R for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 17:20:43 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87LKKAn022173 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 17:20:20 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q87LKJ7m017415; Fri, 7 Sep 2012 17:20:19 -0400 Message-ID: <504A6512.8040802@redhat.com> Date: Fri, 07 Sep 2012 15:20:18 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> <504A5F81.3030005@tlinx.org> In-Reply-To: <504A5F81.3030005@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig6C91803221DCE86C82B19EB3" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6C91803221DCE86C82B19EB3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 02:56 PM, Linda Walsh wrote: > Really, I didn't say rm -fr . should *delete* the current directory -- > IT SHOULD > FAIL -- you are 100% correct. >=20 > But it is true that anyone who knows the smallest bit about unix knows > that you have to empty the directory before deleting the directory, and= , > thus, "rm" _MUST_ do a depth first traversal. If it did and gave an er= ror > at the end: no issue. Indeed, reading the original V7 source code from 1979: http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/rm.c while(--argc > 0) { if(!strcmp(*++argv, "..")) { fprintf(stderr, "rm: cannot remove `..'\n"); continue; } rm(*argv, fflg, rflg, iflg, 0); } shows that _only_ ".." was special, "." was attempted in-place and didn't fail until the unlink(".") after the directory itself had been emptied. It wasn't until later versions of code that "." also became special. You therefore may have a valid point that POSIX standardized something that did not match existing practice at the time, and therefore, it would be reasonable to propose a POSIX defect that requires early failure on "..", but changes the behavior on "." and "/" to only permit, but not require, early failure. However, I just checked, and the prohibition for an early exit on "." has been around since at least POSIX 2001, so you are now coming into the game at least 11 years late. So, until you take it up with the POSIX folks, I don't think anyone on the coreutils side cares enough to bother changing the default behavior, now that it has been standardized, and even though the standardized behavior is tighter than the original pre-standard behavior. > Griping against POSIX is like griping against the government. No, I actually find the Austin Group quite reasonable to work with, especially if you can provide backup evidence like the V7 source snippet I just mentioned. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig6C91803221DCE86C82B19EB3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSmUTAAoJEKeha0olJ0NqjQoH/0CSH/Vi24x9zeHzJ0GpXZ99 ZqcpBv9+P4jhvX+CDlFAOxtWsounHjp6+oKZJ2RIEkq9E+eFCa4p0SCd7AXc+9mA EeCqnae4bObzwYiJT2wgn+LNhvdvsKycg3hKn6mnyRPFdmbCbkAHkWGxfT8Pp96R CC5/5QGuSm327ucIe1mJZHk7B/5Z1Hzl6W3t6oKi84ng+F4ejUjAloXqs+3l3mra 33FKuPufRaCNF/jORj/F2JuOT5Q6TDDiE7MX2pEkPhRMs5UOTJbxYrPOn7XYIDO8 bPEBLQ6x68zpzNHPOX5gtJ1sai62LWHGceCc0w9qO+wvsp+qHLzeAC1Xu2/E/Wg= =K0Ow -----END PGP SIGNATURE----- --------------enig6C91803221DCE86C82B19EB3-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 17:31:15 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 21:31:15 +0000 Received: from localhost ([127.0.0.1]:47256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA68x-0002bU-Ed for submit@debbugs.gnu.org; Fri, 07 Sep 2012 17:31:15 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:58898 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA68v-0002bN-AD for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 17:31:14 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87LUoqC573755; Fri, 7 Sep 2012 14:30:52 -0700 Message-ID: <504A678A.5060603@tlinx.org> Date: Fri, 07 Sep 2012 14:30:50 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> <504A5F81.3030005@tlinx.org> <504A6512.8040802@redhat.com> In-Reply-To: <504A6512.8040802@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: > > You therefore may have a valid point that POSIX standardized something > that did not match existing practice at the time, and therefore, it > would be reasonable to propose a POSIX defect that requires early > failure on "..", but changes the behavior on "." and "/" to only permit, > but not require, early failure. However, I just checked, and the > prohibition for an early exit on "." has been around since at least > POSIX 2001, so you are now coming into the game at least 11 years late. ---- Those changes only started hitting the field a few years ago. Bash just started working to adopted the 2003 standard with it's 4.0 version -- before that it was 1999 -- I didn't even know there was a 2001.... Except that trying to get them to change things now, I'd encounter the same arguments I get here -- that users expect to be able have "-f" not really mean force -- and to report errors on ".". Not that I believe that, -- I just think most users aren't aware or don't care, but that would be the reasoning. I get it here, why would I expect someone who's job is to come up with lame rules that defy standard practice (last I looked they were proposing to ban "space" (as well as 0x01-0x1f) in file names). Attempting to deal with people who want to turn POSIX into a restriction document -- not a standard reflecting current implementations, is well beyond my social abilities. I can't even get engineers -- when faced with clear evidence of programs that put out inconsistent output to fix them. They know it's bad output -- and even warn that they are about to do the wrong thing in warnings. Somehow this is considered preferable to doing something useful. So expecting a group that is heavily into bureaucracy to listen to reason just doesn't seem like a reasonable expectation. I did go to their website though and see what they were discussing, and when I saw that sentiment was going in favor of limiting allowed characters in filenames, I was to ill to stay. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 18:09:08 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 22:09:08 +0000 Received: from localhost ([127.0.0.1]:47287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA6jc-0003SP-EK for submit@debbugs.gnu.org; Fri, 07 Sep 2012 18:09:08 -0400 Received: from c-67-162-91-36.hsd1.in.comcast.net ([67.162.91.36]:59739 helo=kosh.dhis.org) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1TA6jZ-0003SI-Ok for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 18:09:06 -0400 Received: (qmail 26957 invoked by uid 1000); 7 Sep 2012 22:08:44 -0000 Message-ID: <20120907220844.26956.qmail@kosh.dhis.org> From: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it To: eblake@redhat.com (Eric Blake) Date: Fri, 7 Sep 2012 17:08:44 -0500 (GMT+5) In-Reply-To: <504A6512.8040802@redhat.com> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eric Blake writes: > > Indeed, reading the original V7 source code from 1979: > http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/rm.c > [...] > > shows that _only_ ".." was special, "." was attempted in-place and > didn't fail until the unlink(".") after the directory itself had been > emptied. It wasn't until later versions of code that "." also became > special. [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 2.4 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eric Blake writes: > > Indeed, reading the original V7 source code from 1979: > http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/rm.c > [...] > > shows that _only_ ".." was special, "." was attempted in-place and > didn't fail until the unlink(".") after the directory itself had been > emptied. It wasn't until later versions of code that "." also became > special. [...] Content analysis details: (2.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Eric Blake writes: > > Indeed, reading the original V7 source code from 1979: > http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/rm.c > [...] > > shows that _only_ ".." was special, "." was attempted in-place and > didn't fail until the unlink(".") after the directory itself had been > emptied. It wasn't until later versions of code that "." also became > special. I also decided to look around there, and found some of the turning points: Up to 4.2BSD, the V7 behavior was kept. (http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/bin/rm.c) rm -rf . was forbidden in 4.3BSD (26 years ago). http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD/usr/src/bin/rm.c The removal of dir/. (and dir/..) was not forbidden until Reno. http://minnie.tuhs.org/cgi-bin/utree.pl?file=4.3BSD-Reno/src/bin/rm/rm.c cp = rindex(arg, '/'); if (cp == NULL) cp = arg; else ++cp; if (isdot(cp)) { fprintf(stderr, "rm: cannot remove `.' or `..'\n"); return (0); } Maybe the classical behavior stuck around longer in the more SysV-ish Unices. The Ultrix-11 3.1 tree on TUHS from 1988 has a rm that looks very much like V7, but I can't find anything to compare it to until OpenSolaris. Did POSIX force BSD to change their rm in 1988? I think it's more likely that POSIX simply documents a restriction that BSD had already added. Either way the latest POSIX revisions certainly can't be blamed. -- Alan Curry From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 18:51:44 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 22:51:44 +0000 Received: from localhost ([127.0.0.1]:47332 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA7Op-0004Sv-RG for submit@debbugs.gnu.org; Fri, 07 Sep 2012 18:51:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50385) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA7Om-0004Sk-2h for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 18:51:42 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87MpI51007839 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 18:51:19 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q87MpIZg007734; Fri, 7 Sep 2012 18:51:18 -0400 Message-ID: <504A7A65.5040206@redhat.com> Date: Fri, 07 Sep 2012 16:51:17 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> <504A5F81.3030005@tlinx.org> <504A6512.8040802@redhat.com> <504A678A.5060603@tlinx.org> In-Reply-To: <504A678A.5060603@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigBE72249A59C6DE3D57F6CE4A" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBE72249A59C6DE3D57F6CE4A Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 03:30 PM, Linda Walsh wrote: > Not that I believe that, -- I just think most users aren't > aware or don't care, but that would be the reasoning. I get it here, > why would I expect someone who's job is to come up with lame rules that= > defy standard practice (last I looked they were proposing to ban "space= " > (as well as 0x01-0x1f) in file names). You aren't looking very hard, then. The proposal currently being considered by the Austin Group is a ban on newline (and newline only) from file names, because that is the one and only character whose presence in file names causes ambiguous output for line-oriented tools. Forbidding space and most non-printing control characters was rejected as impractical. And even with the proposed ban on newline, it is still just that - a proposal, and not a hard rule, waiting for implementation practice to see if it is even doable. http://www.austingroupbugs.net/view.php?id=3D251 Read the whole thing. The original poster mentioned a much tighter bound, but it was shot down, with the _only_ thing being left on the table under current discussion is _just_ the limitation of newline. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigBE72249A59C6DE3D57F6CE4A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSnplAAoJEKeha0olJ0NqFKMH/38eGbf7gXsPX7RN5IJaKcxx R0MoMbvDLW8ekH8HGY+U4gh76hiEIe+tZLDrErS3iAdHxOni23vcDpmIh5sDVFda 3NuADfKQwcZwSSrCihIJy8pok4mRdxIqxf9GO/l21xbmg7JLzsWaN8osN2ULiUuA cVNTfqmYE/aAYVoh3KJ1SzZox2usuL3ukSjYKJozyPKDeCHmBhcgsehT5N+xgGO3 kttgn5n29nvlYcVIzomXoh2Tc0Z0bnnLHPxIcLKeyEieCr7kg1+EVTHjKI4MUcJg uu/qJeaBg0fMWQ2kNMPbokSYysBBeGv5WhvTHVXPYSMu62Gz78rGA0cD7zE4vI8= =SAPz -----END PGP SIGNATURE----- --------------enigBE72249A59C6DE3D57F6CE4A-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 19:25:56 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 23:25:56 +0000 Received: from localhost ([127.0.0.1]:47353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA7vw-0005ES-DR for submit@debbugs.gnu.org; Fri, 07 Sep 2012 19:25:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62857) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA7vs-0005EJ-MS for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 19:25:55 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q87NPVDq021314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 19:25:31 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q87NPU0N021559; Fri, 7 Sep 2012 19:25:30 -0400 Message-ID: <504A8269.1090006@redhat.com> Date: Fri, 07 Sep 2012 17:25:29 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> <504A5F81.3030005@tlinx.org> <504A6512.8040802@redhat.com> In-Reply-To: <504A6512.8040802@redhat.com> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig667E16244F2A8BFDE3E2991C" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig667E16244F2A8BFDE3E2991C Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 03:20 PM, Eric Blake wrote: > Indeed, reading the original V7 source code from 1979: > http://minnie.tuhs.org/cgi-bin/utree.pl?file=3DV7/usr/src/cmd/rm.c >=20 > shows that _only_ ".." was special, "." was attempted in-place and > didn't fail until the unlink(".") after the directory itself had been > emptied. It wasn't until later versions of code that "." also became > special. >=20 > You therefore may have a valid point that POSIX standardized something > that did not match existing practice at the time, and therefore, it > would be reasonable to propose a POSIX defect that requires early > failure on "..", but changes the behavior on "." and "/" to only permit= , > but not require, early failure. However, I just checked, and the > prohibition for an early exit on "." has been around since at least > POSIX 2001, so you are now coming into the game at least 11 years late.= In addition to Alan's argument that 4.3BSD forbade '.' before POSIX began (and therefore the POSIX folks DID standardize existing practice, even it wasn't universally common at the time), I find this statement from POSIX quite informative (line 104265 in POSIX 2008), on why any proposal to allow 'rm -rf .' to remove non-dot files will probably be denied: >> The rm utility is forbidden to remove the names dot and dot-dot in ord= er to avoid the consequences of inadvertently doing something like: >> rm =E2=88=92r .* --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig667E16244F2A8BFDE3E2991C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSoJqAAoJEKeha0olJ0NqvtQH/AnAndx1SepXzoH/Er3+DZrw 2xPRDs1fvGKMlKV2CmPZ9ZpMxmILzj06oHlkhkRrmUarHJ9QTBygKtJiO0uNxXWg waX1QYQZq1sL3lk4TWHJOZEmBJrx0eG/4KbM+6T1XmdCE3aRFQBfcfE5+3WDfjFP hWrHlT8UXMsDihDxr46EvqBpGUzhS91Vhx5aJC34sOrvoqpwX9tLaiXojKBQ3LJ1 Q6uIkNVlN43xXOgdG+RdzMry1E8zpVbKbYUoTASAvDynFwymLHbsEnZBPfu3kznc nRqm/dlYrn6n3aMNFnUBPrcdCE/APS1HcSMsDsM4mwc6XMXs+8aYssL77D43rkE= =ay7m -----END PGP SIGNATURE----- --------------enig667E16244F2A8BFDE3E2991C-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 19:40:41 2012 Received: (at 12339) by debbugs.gnu.org; 7 Sep 2012 23:40:41 +0000 Received: from localhost ([127.0.0.1]:47362 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8AB-0005ZG-Sh for submit@debbugs.gnu.org; Fri, 07 Sep 2012 19:40:40 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:34503 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8A8-0005Z7-CQ for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 19:40:37 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q87NeCnJ595903; Fri, 7 Sep 2012 16:40:15 -0700 Message-ID: <504A85DC.1060808@tlinx.org> Date: Fri, 07 Sep 2012 16:40:12 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <20120906164215.GA19913@hysteria.proulx.com> <504A0AC0.3070601@tlinx.org> <504A211C.9050303@redhat.com> <504A5F81.3030005@tlinx.org> <504A6512.8040802@redhat.com> <504A8269.1090006@redhat.com> In-Reply-To: <504A8269.1090006@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q87NeCnJ595903 X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Bob Proulx , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: >>> The rm utility is forbidden to remove the names dot and dot-dot in or= der to avoid the consequences of inadvertently doing something like: >>> rm =E2=88=92r .* --- Which is why, IMO, I thought rm -r .* should ask if they really want to r= emove all files under "." as the first question, as it would show up first in s= uch a situation. As stated before, I am more interested in the "-f"=3Dforce it anyway opti= on, that says to let it fail, and continue, ignoring failure. I think that may be where the problem has been introduced. I never used rm - . Certainly rm ** is easier to mistype than rm -r .* so by that logic, that should be disallowed as well? I submit it is the behavior of "-f" that has changed -- and that it used to mean "force" -- continue in spite of errors, and it is that behavior that has changed, as I would would always have expected rm -r . to at least return some error I didn't care about -- What I wanted was the depth-first removal, and -f to force it to continue despit= e errors. How long has -f NOT meant "--force" -- as now it only overlooks write protection errors which sounds very weak. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 20:01:56 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 00:01:56 +0000 Received: from localhost ([127.0.0.1]:47383 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8Ul-000654-TC for submit@debbugs.gnu.org; Fri, 07 Sep 2012 20:01:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65202) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8Ug-00064t-4M for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 20:01:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8801OcH026083 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 7 Sep 2012 20:01:24 -0400 Received: from [10.3.113.60] (ovpn-113-60.phx2.redhat.com [10.3.113.60]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8801MSS022243; Fri, 7 Sep 2012 20:01:23 -0400 Message-ID: <504A8AD1.6050204@redhat.com> Date: Fri, 07 Sep 2012 18:01:21 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> <504A052E.50900@tlinx.org> <504A08C9.4030003@redhat.com> <504A0CA2.4040103@tlinx.org> In-Reply-To: <504A0CA2.4040103@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig85F6E55305434D81F8FD89D8" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -6.9 (------) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig85F6E55305434D81F8FD89D8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 09:02 AM, Linda Walsh wrote: >=20 > --- src/remove.c 2011-10-10 00:56:46.000000000 -0700 > +++ src/remove.c.new 2012-09-06 14:28:07.816810683 -0700 Thanks for making an attempt to show what you want in code. However, you provided no ChangeLog entry, no mention in NEWS and no documentation. Also, you do not have copyright assignment on file with the FSF (but if you'd like to pursue this patch further, we can help you complete the copyright assignment paperwork). Therefore, this patch cannot be taken as-is. > @@ -203,6 +232,7 @@ >=20 > int dirent_type =3D is_dir ? DT_DIR : DT_UNKNOWN; > int write_protected =3D 0; > + int special_delete_content =3D 0; Furthermore, your indentation appears hideous in this email; I'm not sure you created the patch, and whether this is an artifact of your mailer corrupting things or whether you really did disregard existing indentation, but you'd have to clean that up before your patch can be anywhere worth including. > + char * action =3D > special_delete_content > + = =20 > ? _("delete contents of") > + = =20 > : _("descend into"); > + fprintf (stderr, > + (write_protected > + = =20 > ? _("%s: %s write-protected directory %s? ") > + = =20 > : _("%s: %s directory %s? ")), This is a translation no-no (not to mention that your hideous indentation made it hard to read because it was so much longer than 80 columns). Please don't split English sentences across two separate _() calls that are then pasted together, but rather write two _() calls of the two complete sentences. > +++ src/rm.c 2012-09-06 13:33:04.132500554 -0700 > @@ -206,6 +206,7 @@ > bool preserve_root =3D true; > struct rm_options x; > bool prompt_once =3D false; > + x.posix_correctly =3D (getenv ("POSIXLY_CORRECT") !=3D NULL ); Elsewhere in coreutils, we name such a variable posixly_correct, not posix_correctly. And finally, remember my advice - if you want this mode, add it as a new long option, and NOT as an abuse of POSIXLY_CORRECT, if you want to avoid controversy and even stand a chance of getting it approved for inclusion. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig85F6E55305434D81F8FD89D8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSorSAAoJEKeha0olJ0NqIw0H/jtRrdcB+DoYIz+MrFXL+uR1 cJ5bT8HtmdofG7eH41O9RhIIwJ4IeQ3Wy+dpMIEJiqPfKnmot0ryplS30e6Y+Gke o7kMPnIyHmNG2QJAvWULT5NCg6Xt4F0ce0y7kvofUzhpM7cE4HfunWdZs+dWyoNv FxMICQpSO6equfLIt0dVMiU4lzrK3gPhYPMQGLFR86rw2Q9vE/fSjNvxRwGEkNqt MSpNf0RAKJrTh2xG5AFhtqjKRhhmtfEmuQNVjZ4mvw/w8qPJDkuYwfQGm/M/Sx1u OBVigO7w8q1sfL1W57W4iZWmcG+WqNhIl8dzt4YxszOOXXGBFyohgKA7zF502is= =ZZ9P -----END PGP SIGNATURE----- --------------enig85F6E55305434D81F8FD89D8-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 20:03:06 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 00:03:07 +0000 Received: from localhost ([127.0.0.1]:47389 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8Vt-000676-Ri for submit@debbugs.gnu.org; Fri, 07 Sep 2012 20:03:06 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:35597 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8Vq-00066w-GP for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 20:03:04 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8802dt1599658; Fri, 7 Sep 2012 17:02:41 -0700 Message-ID: <504A8B1F.7060602@tlinx.org> Date: Fri, 07 Sep 2012 17:02:39 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Alan Curry Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> In-Reply-To: <20120907220844.26956.qmail@kosh.dhis.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Eric Blake , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Alan Curry wrote: > Eric Blake writes: > if (isdot(cp)) { > fprintf(stderr, "rm: cannot remove `.' or `..'\n"); > return (0); --- The thing is, by doing rm -rf on ., I am not trying to remove . or .. I'm trying to remove the files in it. Other wise there is no way to specify, using "rm" to delete the contents of a directory but not the directory itself. I just want to "clean" out a directory -- I don't want to try to delete the directory itself. 4.3BSD is breaking the intended functionality of a depth first *requirement* for rm to remove a dir. It's well known that the contents must be removed before ".", so trying to remove "." should only fail after the depth first traversal -- that would be expected behavior. I'm NOT trying to remove "." I'm using it to indicated that I only want the contents of the directory deleted. It's like using "/" with a symlink to get at the dir, except that doesn't work reliably -- the only thing that works reliably to get at the contents is "." Try -r dir1/ dir2/ -- they'll move dir1 under dir2, the same as without the "-r". The only way for "-r" to address content is by using "." as the source, in cp -a src/. dst[/] Note cp -a src/. dst/. works, but try to "mv", and you get the type of error you'd expect from trying to "destroy" "b/." Note the copy works but not the mv. cp should realize it is writing "." to "." which is illegal -- but it allows it because it knows what the user *wants* to do. 'mv', is stricter -- as you want to move one inode over the top of another. As a "source address, "." is allowed to mean content, but as a destination, it isn't allowed as a writeable destination. That's the problem with "rm", when uing rm -r '.' that specifies the start of a recursive operation where writes will begin, depth first. It's not until the very end that it tries to do the illegal "write (delete)" operation to ".". If 'cp' allows "." as a source, (and even accommodates it as a target for "cp", so should 'rm' allow "." to mean the start of a deletion, but NOT the dir itself. That's the interpretation that cp is using -- as if it was trying to cp the dir itself over the top of the target, it would give an error message, but it doesn't. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 20:19:29 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 00:19:29 +0000 Received: from localhost ([127.0.0.1]:47409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8ll-0006Tw-2U for submit@debbugs.gnu.org; Fri, 07 Sep 2012 20:19:29 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:35853 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8li-0006To-8K for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 20:19:27 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q880IwpN603115; Fri, 7 Sep 2012 17:19:00 -0700 Message-ID: <504A8EF2.6000301@tlinx.org> Date: Fri, 07 Sep 2012 17:18:58 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> <504A052E.50900@tlinx.org> <504A08C9.4030003@redhat.com> <504A0CA2.4040103@tlinx.org> <504A8AD1.6050204@redhat.com> In-Reply-To: <504A8AD1.6050204@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Bernhard Voelker , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: ...codeing stuff... Thanks for the advice... will take it appreciatively, however it was a few hours effort in unfamiliar code. I certainly wouldn't write NEWS/CHANGES if I didn't have an initial agreement that it would go in. More to the point. Others are objecting, (I'm willing to admit some reasonability in the objection) to changing the default behavior. I proposed adding a ENV var that would need to be specified to get the new behavior. Thus it *would not* be changing default behavior. Does everyone get that... as that's been offered as a an acceptable compromise. Vs. the option of adding it as a long option -- that's pushing it too far -- and doesn't work for me. as it's easier for me to maintain and distribute a patch to rm or my own version than it is to have it as a long option. Reason: doing it in rm OR as an ENV var does it in one place and all my code/interactivity benefits . Doing it in a long option -- must be paid for on each use. The cost doesn't work for me nor would it work for anyone considering cost v. benefit. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 20:24:07 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 00:24:08 +0000 Received: from localhost ([127.0.0.1]:47414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8qF-0006aV-Kr for submit@debbugs.gnu.org; Fri, 07 Sep 2012 20:24:07 -0400 Received: from qmta15.emeryville.ca.mail.comcast.net ([76.96.27.228]:51282) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA8qD-0006aM-6k for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 20:24:06 -0400 Received: from omta24.emeryville.ca.mail.comcast.net ([76.96.30.92]) by qmta15.emeryville.ca.mail.comcast.net with comcast id wH7u1j0011zF43QAFQPkGq; Sat, 08 Sep 2012 00:23:44 +0000 Received: from [192.168.0.16] ([24.10.251.25]) by omta24.emeryville.ca.mail.comcast.net with comcast id wQPh1j0020ZdyUg8kQPiC4; Sat, 08 Sep 2012 00:23:43 +0000 Message-ID: <504A900C.8070303@redhat.com> Date: Fri, 07 Sep 2012 18:23:40 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> <504A8B1F.7060602@tlinx.org> In-Reply-To: <504A8B1F.7060602@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig1884B983A5B304A7ABFBD784" X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Alan Curry , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig1884B983A5B304A7ABFBD784 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/07/2012 06:02 PM, Linda Walsh wrote: > The thing is, by doing rm -rf on ., I am not trying to remove . or .. > I'm trying to remove the files in it. >=20 > Other wise there is no way to specify, using "rm" to delete the content= s > of a directory but not the directory itself. Yes there is, and Paul already told it to you: rm -rf * .[!.] .??* >=20 > I just want to "clean" out a directory -- I don't want to try to delete= the > directory itself. Then use the triple-glob. This is portable to both POSIX and to the old implementations we have been discussing. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig1884B983A5B304A7ABFBD784 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQSpAMAAoJEKeha0olJ0Nq4sUIAJc/y/bo3pe4bFLcnPWcOENH HGOebtMy3pq+cY4KS9k19hYUITSIZ9IkpGgGtyubsskwJAkb2Wa66n+Wka7d2wbx c0PUV5flSifi5i2rh+cHEGgrs6QkMpPObLAb7qOcg+0/7aj4kGif3fTIy6n/5jSE US5MVtyKYQClmH6CnKSd2KQGonsCmtO3cdeJX3ykHRNjpfTJ5xaB0xzOPZt6XsuO ve7CAhP5FDLp1+diiRFvv6oF5euhaZZdL5liTmRmk9L0kXqcPNWUEU7An0xs0G+t f3FK0MF/q2s5V3prx0JwaEiDemmDzi4Z303b0pu29U2B4isMnKA3Q7eSv7BGjU0= =W4Zz -----END PGP SIGNATURE----- --------------enig1884B983A5B304A7ABFBD784-- From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 21:25:32 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 01:25:32 +0000 Received: from localhost ([127.0.0.1]:47457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA9nf-00082i-GY for submit@debbugs.gnu.org; Fri, 07 Sep 2012 21:25:32 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:37909 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TA9nc-00082X-7a for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 21:25:29 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q881P31J615582; Fri, 7 Sep 2012 18:25:05 -0700 Message-ID: <504A9E70.2000804@tlinx.org> Date: Fri, 07 Sep 2012 18:25:04 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> <504A8B1F.7060602@tlinx.org> <504A900C.8070303@redhat.com> In-Reply-To: <504A900C.8070303@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Alan Curry , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Eric Blake wrote: > On 09/07/2012 06:02 PM, Linda Walsh wrote: > >> The thing is, by doing rm -rf on ., I am not trying to remove . or .. >> I'm trying to remove the files in it. >> >> Other wise there is no way to specify, using "rm" to delete the contents >> of a directory but not the directory itself. > > Yes there is, and Paul already told it to you: > > rm -rf * .[!.] .??* ---- You must have missed that rm doesn't expand shell globs... and I don't want to get the shell involved for rm'ing files anymore than cp needs to to copy directories or the files in a dir and not the dir. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 22:29:43 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 02:29:43 +0000 Received: from localhost ([127.0.0.1]:47519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAAnn-0001tM-6e for submit@debbugs.gnu.org; Fri, 07 Sep 2012 22:29:43 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:48920) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAAnl-0001tF-G2 for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 22:29:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id EF7FF39E800E; Fri, 7 Sep 2012 19:29:19 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8imjkxyQnokl; Fri, 7 Sep 2012 19:29:19 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6FECA39E8008; Fri, 7 Sep 2012 19:29:19 -0700 (PDT) Message-ID: <504AAD79.7020707@cs.ucla.edu> Date: Fri, 07 Sep 2012 19:29:13 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> <504A8B1F.7060602@tlinx.org> <504A900C.8070303@redhat.com> <504A9E70.2000804@tlinx.org> In-Reply-To: <504A9E70.2000804@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Eric Blake , Alan Curry , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/07/2012 06:25 PM, Linda Walsh wrote: > I don't want to get the shell involved That's not a reasonable constraint. The shell is a standard tool for solving this sort of problem, and involving the shell solves this problem. From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 23:06:42 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 03:06:42 +0000 Received: from localhost ([127.0.0.1]:47534 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TABNZ-0002lj-TK for submit@debbugs.gnu.org; Fri, 07 Sep 2012 23:06:42 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:41223 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TABNX-0002lc-Tq for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 23:06:41 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8836DxI627412; Fri, 7 Sep 2012 20:06:15 -0700 Message-ID: <504AB625.30205@tlinx.org> Date: Fri, 07 Sep 2012 20:06:13 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> <504A8B1F.7060602@tlinx.org> <504A900C.8070303@redhat.com> <504A9E70.2000804@tlinx.org> <504AAD79.7020707@cs.ucla.edu> In-Reply-To: <504AAD79.7020707@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Eric Blake , Alan Curry , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) The shell is one of the things I'm trying not to have a dependency on. It doesn't pass a reliability test as it does too much. I want a utility that removes files -- single files or depth recursive and it can fail on the current dir or target dir -- after finishes like it is documented to do .. or it can fail at the beginning, as long as the -f option said to ignore errors and keep going. I don't want a wildcard solution. It's a wildcard. (Doh!) The issue was changing the default no? You don't think I'm being reasonable by agreeing and saying a non default environment var? Why should cp accept "." as "addressing the contents of a directory, but "rm" be deliberately crippled? We've excluded safety, since no one will get to the option unless they've enabled it and unless they choose force, since the they should get a prompt asking if they want to delete the delete the files in protected directory ".", right? So far no one has addressed when the change in "-f' went in NOT to ignore the non-deletable dir "." and continue recursive delete, as normal behavior would have it do. Posix claims the rational is to prevent accidental deletion of all cur-dir when using rm -r ., however if it is queried in that case, and noting that rm ** is just as dangerous, but not as clean as it 'only' deletes all files, and leaves the dir skeleton. So posix's rationals wouldn't seem to be 1) that important, and 2) would be addressed by sticking with the current behavior or prompting first -- which would make more sense rather than arbitrarily deciding for them and removing the ability for rm to remove just files -- by itself. with no other utilities invoked. Why shouldn't rm have the ability to only target everything under a specified point, rather than always including the point? From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 07 23:34:45 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 03:34:45 +0000 Received: from localhost ([127.0.0.1]:47547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TABoj-0003Pv-EN for submit@debbugs.gnu.org; Fri, 07 Sep 2012 23:34:45 -0400 Received: from c-67-162-91-36.hsd1.in.comcast.net ([67.162.91.36]:59881 helo=kosh.dhis.org) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1TABog-0003Pm-K1 for 12339@debbugs.gnu.org; Fri, 07 Sep 2012 23:34:44 -0400 Received: (qmail 28130 invoked by uid 1000); 8 Sep 2012 03:34:17 -0000 Message-ID: <20120908033417.28129.qmail@kosh.dhis.org> From: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it To: coreutils@tlinx.org (Linda Walsh) Date: Fri, 7 Sep 2012 22:34:17 -0500 (GMT+5) In-Reply-To: <504AB625.30205@tlinx.org> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Linda Walsh writes: > > So far no one has addressed when the change in "-f' went in > NOT to ignore the non-deletable dir "." and continue recursive delete, In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f option is not consulted before rejecting removal of "." so I don't think the change you're referring to is a change at all. -f never had the effect you think it should have. [...] Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.162.91.36 listed in bl.score.senderscore.com] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Eric Blake , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Linda Walsh writes: > > So far no one has addressed when the change in "-f' went in > NOT to ignore the non-deletable dir "." and continue recursive delete, In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f option is not consulted before rejecting removal of "." so I don't think the change you're referring to is a change at all. -f never had the effect you think it should have. [...] Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.162.91.36 listed in bl.score.senderscore.com] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Linda Walsh writes: > > So far no one has addressed when the change in "-f' went in > NOT to ignore the non-deletable dir "." and continue recursive delete, In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f option is not consulted before rejecting removal of "." so I don't think the change you're referring to is a change at all. -f never had the effect you think it should have. -- Alan Curry From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 00:08:16 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 04:08:16 +0000 Received: from localhost ([127.0.0.1]:47564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TACL9-00049c-3e for submit@debbugs.gnu.org; Sat, 08 Sep 2012 00:08:16 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:42999 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TACL6-00049U-6p for 12339@debbugs.gnu.org; Sat, 08 Sep 2012 00:08:13 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8847kNj631930; Fri, 7 Sep 2012 21:07:48 -0700 Message-ID: <504AC492.7040406@tlinx.org> Date: Fri, 07 Sep 2012 21:07:46 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Alan Curry Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120908033417.28129.qmail@kosh.dhis.org> In-Reply-To: <20120908033417.28129.qmail@kosh.dhis.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Eric Blake , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Alan Curry wrote: > Linda Walsh writes: >> So far no one has addressed when the change in "-f' went in >> NOT to ignore the non-deletable dir "." and continue recursive delete, > > In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f > option is not consulted before rejecting removal of "." so I don't think the > change you're referring to is a change at all. -f never had the effect you > think it should have. > If I was using BSD, I would agree. --- But most of my usage has been on SysV compats Solaris, SGI, Linux, a short while on SunOS back in the late 80's, but that would have been before it changed anyway. For all i know it could have been a vendor addin, but that's not the whole point here. Do you want to support making "." illegal for all gnu utils for addressing content? If not, then we should look at making a decision that it can be used to address content and ensure the interface is consistent going forward. I think you'll find many more people against the idea and wondering why it's in 'rm' and why "-f" doesn't really mean ignore all the errors it can and why that one should be specially treated. Of course they also might wonder why rm doesn't follow the necessary algorithm for deleting files -- and delete contents before dying issuing an error for being unable to delete a parent. Which might also raise why -f shouldn't be usable to silence permission or access errors as it was designed to. There are plenty of good reasons aside from BSD historic usage why it should be designed in, especially when it's being tucked away as a non-default behavior that would need environmental triggering to even be available. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 00:42:51 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 04:42:51 +0000 Received: from localhost ([127.0.0.1]:47593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TACsc-0004xc-Ad for submit@debbugs.gnu.org; Sat, 08 Sep 2012 00:42:51 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:52087) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TACsZ-0004xU-Jb for 12339@debbugs.gnu.org; Sat, 08 Sep 2012 00:42:48 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 8F30639E8013; Fri, 7 Sep 2012 21:42:25 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id syO6CJ80zowV; Fri, 7 Sep 2012 21:42:25 -0700 (PDT) Received: from [192.168.1.3] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 1723339E800A; Fri, 7 Sep 2012 21:42:25 -0700 (PDT) Message-ID: <504ACCB2.1090902@cs.ucla.edu> Date: Fri, 07 Sep 2012 21:42:26 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120907220844.26956.qmail@kosh.dhis.org> <504A8B1F.7060602@tlinx.org> <504A900C.8070303@redhat.com> <504A9E70.2000804@tlinx.org> <504AAD79.7020707@cs.ucla.edu> <504AB625.30205@tlinx.org> In-Reply-To: <504AB625.30205@tlinx.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Eric Blake , Alan Curry , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) On 09/07/2012 08:06 PM, Linda Walsh wrote: > The shell is one of the things I'm trying not > to have a dependency on. That sounds unnecessarily impractical. It's been decades since I used a system that had 'rm' but didn't have a shell that could solve this problem easily. By the way, Alan, that was a nice trip down memory lane! I've *used* all those 'rm' implementations. I'm even old enough to remember when 'rm' automatically refused to remove itself. > You don't think I'm being reasonable by agreeing and saying > a non default environment var? No, because then currently-working scripts might have to be changed to guard against that variable being set. Clearly you don't agree with the POSIX rationale. Reasonable people can disagree, and then move on. The nice thing about free software is that you can build your system the way you like. You don't have to convert the rest of us. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 00:57:41 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 04:57:41 +0000 Received: from localhost ([127.0.0.1]:47597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAD6y-0005Hd-OQ for submit@debbugs.gnu.org; Sat, 08 Sep 2012 00:57:41 -0400 Received: from c-67-162-91-36.hsd1.in.comcast.net ([67.162.91.36]:59921 helo=kosh.dhis.org) by debbugs.gnu.org with smtp (Exim 4.72) (envelope-from ) id 1TAD6v-0005HR-BE for 12339@debbugs.gnu.org; Sat, 08 Sep 2012 00:57:39 -0400 Received: (qmail 28569 invoked by uid 1000); 8 Sep 2012 04:57:12 -0000 Message-ID: <20120908045712.28568.qmail@kosh.dhis.org> From: "Alan Curry" Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it To: coreutils@tlinx.org (Linda Walsh) Date: Fri, 7 Sep 2012 23:57:12 -0500 (GMT+5) In-Reply-To: <504AC492.7040406@tlinx.org> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Linda Walsh writes: > > Alan Curry wrote: > > Linda Walsh writes: > >> So far no one has addressed when the change in "-f' went in > >> NOT to ignore the non-deletable dir "." and continue recursive delete, > > > > In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f > > option is not consulted before rejecting removal of "." so I don't think the > > change you're referring to is a change at all. -f never had the effect you > > think it should have. > > > If I was using BSD, I would agree. > --- > But most of my usage has been on SysV compats Solaris, SGI, Linux, a short > while on SunOS back in the late 80's, but that would have been before it > changed anyway. [...] Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.162.91.36 listed in bl.score.senderscore.com] 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Eric Blake , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Linda Walsh writes: > > Alan Curry wrote: > > Linda Walsh writes: > >> So far no one has addressed when the change in "-f' went in > >> NOT to ignore the non-deletable dir "." and continue recursive delete, > > > > In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f > > option is not consulted before rejecting removal of "." so I don't think the > > change you're referring to is a change at all. -f never had the effect you > > think it should have. > > > If I was using BSD, I would agree. > --- > But most of my usage has been on SysV compats Solaris, SGI, Linux, a short > while on SunOS back in the late 80's, but that would have been before it > changed anyway. [...] Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.3 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL [67.162.91.36 listed in zen.spamhaus.org] 0.0 RCVD_IN_SORBS_DUL RBL: SORBS: sent directly from dynamic IP address [67.162.91.36 listed in dnsbl.sorbs.net] 1.3 RCVD_IN_RP_RNBL RBL: Relay in RNBL, https://senderscore.org/blacklistlookup/ [67.162.91.36 listed in bl.score.senderscore.com] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS Linda Walsh writes: > > Alan Curry wrote: > > Linda Walsh writes: > >> So far no one has addressed when the change in "-f' went in > >> NOT to ignore the non-deletable dir "." and continue recursive delete, > > > > In the historic sources I pointed out earlier (4.3BSD and 4.3BSD-Reno) the -f > > option is not consulted before rejecting removal of "." so I don't think the > > change you're referring to is a change at all. -f never had the effect you > > think it should have. > > > If I was using BSD, I would agree. > --- > But most of my usage has been on SysV compats Solaris, SGI, Linux, a short > while on SunOS back in the late 80's, but that would have been before it > changed anyway. SGI is dead, Sun is dead, the game's over, we're the winners, and our rm has been this way forever. > > For all i know it could have been a vendor addin, but that's > not the whole point here. > > Do you want to support making "." illegal for all > gnu utils for addressing content? I don't think "addressing content" is a clearly defined operation, no matter how many times you repeat it. Consistency between tools is a good thing, but consistency between OSes is also good, and we'd be losing that if any change was made to GNU rm's default behavior. Even OpenSolaris has the restriction: see lines 160-170 of http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/rm/rm.c > > I think you'll find many more people against the idea and wondering > why it's in 'rm' and why "-f" doesn't really mean ignore all the errors > it can and why that one should be specially treated. Of course they also might > wonder why rm doesn't follow the necessary algorithm for deleting files -- > and delete contents before dying issuing an error for being unable to delete > a parent. Which might also raise why -f shouldn't be usable to silence permission > or access errors as it was designed to. Look, I agree isn't not logical or elegant. But we have a standard that all current Unices are obeying, and logic and elegance alone aren't enough to justify changing that. A new option that you can put in an alias is really the most realistic goal. -- Alan Curry From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 03:09:43 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 07:09:43 +0000 Received: from localhost ([127.0.0.1]:47704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAFAl-0008Jk-8u for submit@debbugs.gnu.org; Sat, 08 Sep 2012 03:09:43 -0400 Received: from mx.meyering.net ([88.168.87.75]:52361) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAFAi-0008Ja-Pj for 12339@debbugs.gnu.org; Sat, 08 Sep 2012 03:09:41 -0400 Received: from rho.meyering.net (rho.meyering.net [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id D2E3760121; Sat, 8 Sep 2012 09:09:16 +0200 (CEST) From: Jim Meyering To: Linda Walsh Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it is documented to do so. In-Reply-To: <504A8EF2.6000301@tlinx.org> (Linda Walsh's message of "Fri, 07 Sep 2012 17:18:58 -0700") References: <5043FA91.9070703@tlinx.org> <877gsbk1kz.fsf@rho.meyering.net> <5044C016.2030807@tlinx.org> <50450D4F.8010908@cs.ucla.edu> <877gsac5h4.fsf@rho.meyering.net> <5046101F.8080108@bernhard-voelker.de> <87mx15bzl9.fsf@rho.meyering.net> <504620B5.2040406@cs.ucla.edu> <5048179A.1010005@tlinx.org> <87fw6v3ai3.fsf@rho.meyering.net> <50488153.506@tlinx.org> <87obljz9jf.fsf@rho.meyering.net> <504A01C9.7030005@tlinx.org> <504A0357.6050806@redhat.com> <504A052E.50900@tlinx.org> <504A08C9.4030003@redhat.com> <504A0CA2.4040103@tlinx.org> <504A8AD1.6050204@redhat.com> <504A8EF2.6000301@tlinx.org> Date: Sat, 08 Sep 2012 09:09:16 +0200 Message-ID: <87vcfprnxf.fsf@rho.meyering.net> Lines: 15 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Eric Blake , Bernhard Voelker , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Linda Walsh wrote: > I proposed adding a ENV var that would need to be specified to get > the new behavior. Thus it *would not* be changing default behavior. > > Does everyone get that... as that's been offered as a an acceptable > compromise. We will not be adding new behavior that is enabled by an environment variable. I explained a similar refusal for sort.c just two weeks ago: https://lists.gnu.org/archive/html/coreutils/2012-08/msg00172.html > ... we have a strong aversion to adding > support for new environment variables in coreutils programs > because it makes formerly-robust usage prone to malfunction or abuse. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 08 15:21:56 2012 Received: (at 12339) by debbugs.gnu.org; 8 Sep 2012 19:21:56 +0000 Received: from localhost ([127.0.0.1]:49053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAQbL-0002Ye-Nv for submit@debbugs.gnu.org; Sat, 08 Sep 2012 15:21:56 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:40049 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TAQbJ-0002YV-7h for 12339@debbugs.gnu.org; Sat, 08 Sep 2012 15:21:54 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q88JLIoA731560; Sat, 8 Sep 2012 12:21:20 -0700 Message-ID: <504B9AAE.5000507@tlinx.org> Date: Sat, 08 Sep 2012 12:21:18 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Alan Curry Subject: Re: bug#12339: Bug: rm -fr . doesn't dir depth first deletion yet it References: <20120908045712.28568.qmail@kosh.dhis.org> In-Reply-To: <20120908045712.28568.qmail@kosh.dhis.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 12339 Cc: Paul Eggert , Eric Blake , 12339@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) Alan Curry wrote: > SGI is dead, Sun is dead, the game's over, we're the winners, and our rm has > been this way forever. ---- Until you learn that you are played off by your masters against others, and that the only real win is a win-win, you are just a losing pawn in a game. > I don't think "addressing content" is a clearly defined operation, no matter > how many times you repeat it. --- Until you are able to understand content addressability, you won't understand the importance or need for doing so. Without targeted addressing all you have a blunt intstruments, you might as well go back to bear skins and stone knives to match the 'we must conquer' mentality, that is it's evolutionary equal. > Consistency between tools is a good thing, but consistency between OSes is > also good, and we'd be losing that if any change was made to GNU rm's default > behavior. Even OpenSolaris has the restriction: see lines 160-170 of > http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/cmd/rm/rm.c ---- Rationalizations to avoid coming to a something that works for everyone. > A new option that you can put in an alias is really the most realistic goal. --- Aliases don't work when you issue 'exec'. They aren't able to be exported or inherited by subsequent processes -- something I have asked for multiple times, for exactly this type of issue. As it is, you suggest a cripple solution to deal with crippled functionality. You and others are demonstrating the current level of ability they possess in order to solve problems, and the overriding priority of corporate compliance. Diversity is an anathema to your thinking. In the end result of control - Gnu seems little different from those the rally against. It is only their methods that differ, but they both equally end up mandating their solutions through the means they have. Is Gnu's distribution process open or closed source? And by open -- it includes all the software and codes necessary to make changes to the distribution. I would think that unlikely. This is not an isolated incident. It may not be tied solely to gender, but I have had other women comment on similar experiences in the male-owned software industry. You are only demonstrating what good soldiers you are in the service of your masters. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 18:52:48 2012 Received: (at 12339) by debbugs.gnu.org; 12 Sep 2012 22:52:48 +0000 Received: from localhost ([127.0.0.1]:58060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBvna-00038K-JN for submit@debbugs.gnu.org; Wed, 12 Sep 2012 18:52:47 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:57331 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBvnX-00038C-56 for 12339@debbugs.gnu.org; Wed, 12 Sep 2012 18:52:45 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8CMppwE775492; Wed, 12 Sep 2012 15:51:53 -0700 Message-ID: <50511207.2010108@tlinx.org> Date: Wed, 12 Sep 2012 15:51:51 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: "12339@debbugs.gnu.org" <12339@debbugs.gnu.org>, Jim Meyering Subject: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) Content-Type: multipart/alternative; boundary="------------040900070709070005080803" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------040900070709070005080803 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I hope to prove the subject convincingly in the following sections, If you can, reading this in the original HTML might be useful, as I don't know it will end up when converted to text. I tried to format it for readability .. so if the text format isn't...(still tried to limit margins and use monospace font)... Writing this to appeal to those with an open mind is the best I can hope for. I. In regards to /*Compatibility with Default Behavior*/. If there is a change to a function or functionality that people use, then you have broken compatibility with past functionality. If it was something that generated an error in the past, fixing it doesn't break compatibility with past function. Example: > mkdir aaa > ln -s aaa bbb > rm -r bbb ## deletes symlink 'recursively' leaving ## aaa untouched. > ln -s aaa bbb > rm -r bbb/ ## this would make it clear that we ## are addressing a dir that bbb is ## pointing to; however... rm: cannot remove directory `bbb': Not a directory. ## rm is confused, as ls shows: > 'ls' -gGld bbb/ drwxrwxr-x 2 6 2012-09-11 09:48 bbb/ Rumor has it 'rm' may now include a fix for this so that it knows that "/" means '/address/ the directory at the end of this symlink'. Did this change default behavior? Yes. Did it change default functional behavior? No. Before, "rm -r bbb/" was not valid syntax -- and wasn't part of "default behavior". A new feature was created where before there was none. Implementing functionality where before there was none, is not normally considered "changing default behavior", as there was no legal or functional prior behavior that someone would have been _relying_ on. To someone unfamiliar with "/" being the directory separator, you could just as easily have added a "/" flag that when appended to a word, tells rm to treat it as a directory. II. Basenames vs. dirnames. What are they? Basenames are the final part of a name that has been chosen to name the entry located in "some dir". Let's look at some different "Cases" of sample pathnames (skipping the easy ones, given the audience): Case A: "/" What is the dirname and what is the basename? Answer: and . That's why it is called the root -- it doesn't have a name entry somewhere as it is the top of the tree -- there is nothing above it to hold a name for it. It has to exist on every system, so by convention, it is called the 'root' directory. Case B: "ENTRY/" What is the dirname and what is the basename? Answer: Dirname="ENTRY", basename=. (Explanation seems unnecessary). Case C: "ENTRY" Dir and Basenames? Answer: it depends on context and what it really is. Whether or not 'ENTRY' is a basename or a dirname depends on whether or not 'ENTRY' is a directory. Example. In it's default mode rm removes only files. I.e. "rm a b c ENTRY d" -- rm expects all entries to to simple basenames. If it encounters a dirname, it issues an error and refuses to operate on it. In it's recursive mode, rm will accept basenames and dirnames. It will inspect each entry to determine if it is a file (basename) or a dir(dirname). As POSIX states: If, on the other hand, you specify the "-r" switch to rm, it enables it to remove directories, but it doesn't treat them the same as other files (because they still are not 'basenames' - they are directories). So the first difference that might be noted, is that rm begins a depth first traversal on the contents of that directory. Once it is empty an is no longer containing any non-structural entries, it will then enable it to be deleted using rmdir (that handles deconstructing internal structural components that unlink wouldn't handle). Only after the contents have been removed is it no longer a dirpath -- and it becomes the next active "operand" of the "rm" verb/action. At that point, it either deletes it or not, depending on what is permitted by policy (usually security settings). There are 2 entries not covered usually covered by security policies, as they are not discretionary entries -- they are mandatory components of the OS, namely "." and "..". If "rm" encounters one of those at the point such an entry becomes the "entry to be operated on" (the operand), POSIX directs that rm shouldn't even try to delete those entries (as on some systems this might succeed, if the underlying OS allows it, so in order to provide portable behavior, a compliant "rm" will not attempt to delete those entries. POSIX states: If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component), rm shall write a diagnostic message to standard error and do nothing more with such operands. However, "rm" if it encounters "." or ".." and the user has specified that they are to be treated as files (i.e. they do no specify -r), "rm" already refuses to delete those entries as they are not normal files or basename components -- but are structural components to facilitate addressing -- specifically ".." allows addressing the directory above the current dir, while "." allows one to specify an explicit starting point for an operation as the root of the current directory. The wording for treatment of "." and ".." is consistent for the case that they are being addressed as "targets" not being used as addresses. POSIX states for directories, with (recursion), For each entry contained in /file/, other than dot or dot-dot, the four steps listed here (1 to 4) shall be taken with the entry as if it were a /file/ operand. The /rm/ utility shall not traverse directories by following symbolic links into other parts of the hierarchy, but shall remove the links themselves. The first thing it does when operating on a directory is to enter the directory and remove associated files. Only when a directory is empty, is it able to be addressed as a file-type operand of the parent that can be removed with 1 operation (rmdir vs. unlink). If, however, you remove the contents, and now when you back up you have been removing contents under ".", then -- discovering "." as an operand, "it should issue an error and have nothing more to do with that file". This is entirely consistent with the wording in POSIX. It would also be the case if "-f" had been specified, that any diagnostic would be suppressed. As POSIX is a computer portability standard, one would imagine that they know the difference between dirnames and basenames and that a dirname can only be treated as a basename when it has been emptied of files. Gnu's version of rm worked as I described prior to version 6. Version 5 in openSuse 10.1 and earlier was only *retired about 4 years ago* -- not "23 years ago" like some people would make up. This is a relatively new change that is causing problems and I would like to see it reverted to the letter of computer science practice -- as it would still adhere to the letter of POSIX's requirements. III) Please note, that just as in section I, we are [re]adding functionality where before there was none. Thus this is no more a compatibility feature than adding any other "new feature", as before, only "dysfunction" existed. Adding new features in the place of a void is not something that can break previous compatibility, as it makes no sense to have dependencies on a void... --------------040900070709070005080803 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.sc.tlinx.org id q8CMppwE775492

I hope to prove the subject convincingly in the following sections, If you can, reading this in the original HTML might be useful, as I don't know it will end up when converted to text. I tried to format it for readability .. so if the text format isn't...(still tried to limit margins and use monospace font)...=C2=A0 Writing this to appeal to those with an open mind
is the best I can hope for.

I. In regards to Compatibility with Default Behavior.=C2=A0 If there is a change to a function or functionality that people use, then you have broken compatibility with past functionality.=C2=A0 If it w= as something that generated an error in the past, fixing it doesn't break compatibility with past function.=C2=A0 Example:

> mkdir aaa
> ln -s aaa bbb
> rm -r bbb=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ## deletes syml= ink 'recursively' leaving
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ## aaa untouched.
> ln -s aaa bbb
> rm -r bbb/=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ## this would make i= t clear that we
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ## are addressing a dir that bbb is
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ## pointing to;=C2=A0 however...

rm: cannot remove directory `bbb': Not a directory.

=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 =C2=A0=C2=A0=C2=A0 ## rm is confused, as ls shows:
> 'ls' -gGld bbb/
drwxrwxr-x 2 6 2012-09-11 09:48 bbb/
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0

Rumor has it 'rm' may now include a fix for this so that it knows that=C2=A0 "/" means 'address the directory at the end of this symlink'.=C2=A0

Did this change default behavior?=C2=A0 Yes.=C2=A0 Did it change defau= lt functional behavior?=C2=A0 No.=C2=A0 Before, "rm -r bbb/" was not valid s= yntax -- and wasn't part of "default behavior".=C2=A0 A new feature was created wh= ere before there was none.=C2=A0

Implementing functionality where before there was none, is not normally considered "changing default behavior", as there was no legal or functional prior behavior that someone would have been _relying_ on.=C2=A0=C2=A0 To someone unfamiliar with "/" being the directory separa= tor, you could just as easily have added a "/" flag that when appended to a word, tells rm to treat it as a directory.

II.=C2=A0 Basenames vs. dirnames.=C2=A0 What are they?=C2=A0 Basenames= are the final part of a name that has been chosen to name the entry located in "some dir". Let's look at some different "Cases" of sample pathnames (skipping the easy ones, given the audience):

Case A:=C2=A0=C2=A0 "/" =C2=A0 =C2=A0 What is the dirname and what is = the basename?

Answer: <null> and <null>.=C2=A0


=C2=A0 That's why it is called the root -- it doesn't have a name entry somewhere as it is the top of the tree -- there is nothing above it to hold a name for it.=C2=A0 It has to exist on every system, so by conventi= on, it is called the 'root' directory.


=C2=A0 Case B: "ENTRY/" =C2=A0 =C2=A0 What is the dirname and what is the= basename?

Answer: Dirname=3D"ENTRY", basename=3D<null>.=C2=A0 (Explanation= seems unnecessary).


=C2=A0 Case C: "ENTRY" =C2=A0=C2=A0 Dir and Basenames?

Answer:=C2=A0 it depends on context and what it really is.

Whether or not 'ENTRY' is a basename or a dirname depends on whether or not 'ENTRY' is a directory.

Example.=C2=A0 In it's default mode rm removes only files.=C2=A0 I.e. =
"rm a b c ENTRY d" -- rm expects all entries to to simple basenames.=C2=A0 If it encounters a dirname, it issues an error and refuses to operate on it.

In it's recursive mode, rm will accept basenames and dirnames.=C2=A0 I= t will
inspect each entry to determine if it is a file (basename) or a dir(dirname).

As POSIX states:

If, on the other hand, you specify the "-r" switch to rm, it enables it to remove directories, but it doesn't treat them the same as other files (because they still are not 'basenames'=C2=A0 - they are directories).=C2=A0 So the first difference that might be noted, is that = rm begins a depth first traversal on the contents of that directory.=C2=A0 O= nce it is empty an is no longer containing any non-structural entries, it will then enable it to be deleted using rmdir (that handles deconstructing internal structural components that unlink wouldn't handle).=C2=A0

Only after the contents have been removed is it no longer a dirpath -- and it becomes the next active "operand" of the "rm" verb/action.

At that point, it either deletes it or not, depending on what is permitted by policy (usually security settings).=C2=A0

There are 2 entries not covered usually covered by security policies, as they are not discretionary entries -- they are mandatory components of the OS, namely "." and "..".=C2=A0=C2=A0 If "rm" encounters= one of those at the point such an entry becomes the "entry to be operated on" (the operand), POSIX directs that rm shouldn't even try to delete those entries (as on some systems this might succeed, if the underlying OS allows it, so in order to provide portable behavior, a compliant "rm" will not attempt to delete those entries.

POSIX states:

If either of the files dot or dot-dot are specified as the basename portion of an operand (that is, the final pathname component), rm shall write a diagnostic message to standard error and do nothing more with such operands.

However, "rm" if it encounters "." or ".." and the user has specified that they are to be treated as files (i.e. they do no specify -r), "rm" already refuses to delete those entries as they are not normal files or basename components -- but are structural components to facilitate addressing -- specifically ".." allows addressing the directory above the current dir, while "." allows one to specify an explicit starting point for an operation as the root of the current directory.=C2=A0

The wording for treatment of "." and ".." is consistent for the case that they are being addressed as "targets" not being used as addresses.

POSIX states for directories, with (recursion),

For each entry contained in file, other than dot or dot-dot, the four steps listed here (1 to 4) shall be taken with the entry as if it were a file operand. The rm utility shall not traverse directories by following symbolic links into other parts of the hierarchy, but shall remove the links themselves.

The first thing it does when operating on a directory is to enter the directory and remove associated files.=C2=A0 Only when a directory is empty,
is it able to be addressed as a file-type operand of the parent that
can be removed with 1 operation (rmdir vs. unlink).=C2=A0 If, however, yo= u remove
the contents, and now when you back up you have been removing contents under
".", then -- discovering "." as an operand, "it should issue an error and have nothing more to do with that file".=C2=A0=C2=A0 This is entirely consistent with
the wording in POSIX.=C2=A0 It would also be the case if "-f" had been specified,
that any diagnostic would be suppressed.

As POSIX is a computer portability standard, one would imagine that they know the difference between dirnames and basenames and that a dirname can only be treated as a basename when it has been emptied of files.

Gnu's version of rm worked as I described prior to version 6.=C2=A0 Version 5
in openSuse 10.1 and earlier was only retired about 4 years ago -- not "23 years ago" like some people would make up.=C2=A0=C2=A0 This is= a relatively new change
that is causing problems and I would like to see it reverted to the letter
of computer science practice -- as it would still adhere to the letter of POSIX's requirements.



III)=C2=A0 Please note, that just as in section I, we are [re]adding functionality where before there was none.=C2=A0=C2=A0 Thus this is no mo= re a compatibility feature than adding any other "new feature", as before,
only "dysfunction" existed.=C2=A0 Adding new features in the place of a v= oid
is not something that can break previous compatibility, as it makes no sense to have dependencies on a void...





--------------040900070709070005080803-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 20:29:32 2012 Received: (at 12339) by debbugs.gnu.org; 13 Sep 2012 00:29:32 +0000 Received: from localhost ([127.0.0.1]:58098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBxJD-0005IA-5Y for submit@debbugs.gnu.org; Wed, 12 Sep 2012 20:29:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49259) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBxJ8-0005I0-P5 for 12339@debbugs.gnu.org; Wed, 12 Sep 2012 20:29:30 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8D0Sa6T028422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Sep 2012 20:28:36 -0400 Received: from [10.3.113.57] (ovpn-113-57.phx2.redhat.com [10.3.113.57]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8D0SaEa008617; Wed, 12 Sep 2012 20:28:36 -0400 Message-ID: <505128B2.6000008@redhat.com> Date: Wed, 12 Sep 2012 18:28:34 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: Linda Walsh Subject: Re: bug#12339: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) References: <5043FA91.9070703@tlinx.org> <50511207.2010108@tlinx.org> In-Reply-To: <50511207.2010108@tlinx.org> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig10039625D7B194917790EE42" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -7.3 (-------) X-Debbugs-Envelope-To: 12339 Cc: Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -7.3 (-------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig10039625D7B194917790EE42 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/12/2012 04:51 PM, Linda Walsh wrote: > I hope to prove the subject convincingly in the following sections, If > you can, reading this in the original HTML might be useful, as I don't > know it will end up when converted to text. HTML mail is forbidden on this list; the mail engine stripped it to plain text before it ever hit the list or the online bug report: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D12339#239 > I tried to format it for > readability .. so if the text format isn't...(still tried to limit > margins and use monospace font)... So please bear with me if my inability to see your intended markup means that I misinterpret your intent. > Before, "rm -r bbb/" was not valid syntax -- Sorry, but 'rm -r bbb/' has ALWAYS been valid syntax in POSIX, and has always meant 'remove the directory found by resolving 'bbb', even if 'bbb' is a symlink to a directory. The fact that the Linux kernel rmdir("bbb/") has not always followed POSIX in this regards makes it harder to use as a use case - because then we are torn with whether to honor the kernel decision of how it should behave or whether to pay the penalty of a slower wrapper function that does it the way POSIX says it should behave. The best we can do is document which way we have chosen to go. > II. Basenames vs. dirnames. What are they? Basenames are the final > part of a name that has been chosen to name the entry located in "some > dir". They are also well-defined terms in the POSIX standard. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#t= ag_03_40 http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html Let's look at some different "Cases" of sample pathnames (skipping > the easy ones, given the audience): >=20 > Case A: "/" What is the dirname and what is the basename? >=20 > Answer: and . Unfortunately, your interpretation is not consistent with the POSIX definitions. The POSIX-mandated answer is a dirname of '/' and a basename of '/'. Additionally, this particular file name is always a directory. > Case B: "ENTRY/" What is the dirname and what is the basename? >=20 > Answer: Dirname=3D"ENTRY", basename=3D. (Explanation seems unnec= essary). Unfortunately, your interpretation is not consistent with the POSIX definitions. The POSIX-mandated answer is a dirname of '.' and a basename of 'ENTRY'. Additionally, this particular file name must always resolve to a directory (that is, either 'ENTRY' is a directory, or 'ENTRY' is a symlink whose eventual target is a directory). > Case C: "ENTRY" Dir and Basenames? >=20 > Answer: it depends on context and what it really is. Unfortunately, your interpretation is not consistent with the POSIX definitions. The POSIX-mandated answer is a dirname of '.' and a basename of 'ENTRY'. But you are correct that it may or may not be a directory. >=20 > Whether or not 'ENTRY' is a basename or a dirname depends on whether or= > not 'ENTRY' is a directory. Rather, the POSIX definition states that 'ENTRY' is a basename because it is the last non-slash component of the overall string, after stripping any trailing slashes. Remember, a directory is ALSO a file, just like a symlink or a socket or a character device is also a file. The term basename applies to any file, not just non-directory files. >=20 > Example. In it's default mode rm removes only files. Correction - in its default mode, rm removes regular files, symlinks, fifos, block devices, character devices, socket files, and any other implementation extension file types, but has special case treatment of directory files. This special case treatment is mandated by POSIX, to match historical practice. > "rm a b c ENTRY d" -- rm expects all entries to to simple basenames. I= f > it encounters a dirname, it issues an error and refuses to operate on i= t. Correcting your terminology: If it encounters a *directory*, it issues an error and refuses to operate on it. Remember, _every single file name_ has both a dirname and a basename, even if the dirname is the implied '.', so all five of the arguments in your examples include a basename as part of the name. But that does not tell us whether the file is a directory, a regular file, or some other type of file. >=20 > In it's recursive mode, rm will accept basenames and dirnames. It will= > inspect each entry to determine if it is a file (basename) or a > dir(dirname). Again correcting your terminology: rm will accept directories in addition to other file types. > As POSIX states: >=20 > If, on the other hand, you specify the "-r" switch to rm, it enables it= > to remove directories, but it doesn't treat them the same as other file= s > (because they still are not 'basenames' - they are directories). Wrong terminology, but you are correct that directories are handled differently; but that's because unlink() and rmdir() are different functions and so directories MUST be handled differently. > Only after the contents have been removed is it no longer a dirpath -- This statement makes no sense in light of POSIX terminology. Maybe you meant: Only after the contents have been removed is it an empty directory that can be acted on by rmdir(). > There are 2 entries not covered usually covered by security policies, a= s > they are not discretionary entries -- they are mandatory components of > the OS, namely "." and "..". Actually, believe it or not, '.' and '..' are NOT mandatory directory entries in POSIX. It is mandatory that they be handled in file name resolution, but it is possible to have a file system where readdir() never returns '.' or '..'. > As POSIX is a computer portability standard, one would imagine that the= y > know the difference between dirnames and basenames Yes, POSIX has a self-consistent definition of those terms. > and that a dirname > can only be treated as a basename when it has been emptied of files. No, that is not a consistent statement in light of the POSIX definition of the terms. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig10039625D7B194917790EE42 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQUSizAAoJEKeha0olJ0Nq16wH/jK1UGEJWNd+g2UMLd2B/0GC hi21GvppN37y03meKVN403lOrUtLpxnSY5Xsq4D4X6pXCEyWBHAJHkxoQutykR1N wTmuLtnFgfKcl4um9Ob9wIL+ecRlCRv0A+eXcZ6XKW4jpcEjwmsry6DUe5IyJhp/ QMYRJQFZ618NFgUn46dQ/UdEvxJD6qTV2buxwA7s1hYM3gb49+/3SJysq7GfPwDj UmvWd7yRO87T17z86axiuDg1ZpKyqpE99n9Vg0eW3PhVKmxuLyGPNeQ/yIa8OmJL +u0YXyOq4crtZf3M0BSrCmRm84m9imUVluSrws0hHNezVfI9k5mScm94vZKZtRU= =SsVM -----END PGP SIGNATURE----- --------------enig10039625D7B194917790EE42-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 20:51:28 2012 Received: (at 12339) by debbugs.gnu.org; 13 Sep 2012 00:51:28 +0000 Received: from localhost ([127.0.0.1]:58131 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBxeR-0005pF-UH for submit@debbugs.gnu.org; Wed, 12 Sep 2012 20:51:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23577) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBxeO-0005p6-R8 for 12339@debbugs.gnu.org; Wed, 12 Sep 2012 20:51:26 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8D0oY8t004746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Sep 2012 20:50:35 -0400 Received: from [10.3.113.57] (ovpn-113-57.phx2.redhat.com [10.3.113.57]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8D0oXB8025183; Wed, 12 Sep 2012 20:50:34 -0400 Message-ID: <50512DD8.1070006@redhat.com> Date: Wed, 12 Sep 2012 18:50:32 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 Subject: Re: bug#12339: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) References: <5043FA91.9070703@tlinx.org> <50511207.2010108@tlinx.org> <505128B2.6000008@redhat.com> In-Reply-To: <505128B2.6000008@redhat.com> X-Enigmail-Version: 1.4.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig6E8A5D7E21F4C0A69AAA0848" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 12339 Cc: Linda Walsh , Jim Meyering , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6E8A5D7E21F4C0A69AAA0848 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/12/2012 06:28 PM, Eric Blake wrote: >> Before, "rm -r bbb/" was not valid syntax -- >=20 > Sorry, but 'rm -r bbb/' has ALWAYS been valid syntax in POSIX, and has > always meant 'remove the directory found by resolving 'bbb', even if > 'bbb' is a symlink to a directory. The fact that the Linux kernel > rmdir("bbb/") has not always followed POSIX in this regards makes it > harder to use as a use case - because then we are torn with whether to > honor the kernel decision of how it should behave or whether to pay the= > penalty of a slower wrapper function that does it the way POSIX says it= > should behave. On re-reading this, I think a bit more on this topic might help. Remember that remove() is required to call either rmdir() or unlink() as appropriate. On Solaris 10, if 'bbb' is a symlink to an empty directory, then remove("bbb") removes the symlink but leaves the directory; and remove("bbb/") removes the directory, but leaves bbb as a danging symlink. This is the behavior POSIX mandates, but can be non-intuitive if you are not expecting it. On Solaris 8, remove("bbb/") had a bug where it silently ignored the trailing slash, and was blindly treated as remove("bbb"). Even if "bbb" was some other file type, like a regular file, it was still removed. Coreutils works around this bug by using a gnulib module to wrap a large number of Solaris 8 kernel calls that silently ignore trailing slash. On Linux (at least through kernel 3.5.3), remove("bbb") removes the symlink, and remove("bbb/") fails with ENOTDIR, which is contrary to POSIX. The failure intuitively makes more sense (who wants to leave a dangling symlink behind?), although the choice of errno value does not (POSIX requires that bbb/ be treated as a directory, and the symlink does indeed resolve to a directory). But gnulib and coreutils so far have chosen not to penalize Linux with a wrapper around remove(), and instead this means 'rm' currently ends up with non-POSIX behavior because the kernel still has non-POSIX behavior. On all three systems, remove("bbb/.") fails, consistent with the POSIX requirement that the basename of "." cannot be removed directly, but only by rmdir()ing another name for the same directory. In this case, POSIX mandates EINVAL as the failure (not all systems meet this), which is different than the ENOTDIR failure of Linux' remove("bbb/"). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig6E8A5D7E21F4C0A69AAA0848 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQUS3ZAAoJEKeha0olJ0NqCAkH/0TxI2W9N/EHuee8hzWbRj61 OjkvH69K6Elvz7vEl6cnx3dDlAynJSlHKqe2ommHCOCTBxrb98QKVJTvD3IMwVHH FQGsAwJMixu6ROCU8b3dL1RhvzqTh05Jfbmw1+THjlu5cM9UQS6TzV579B7pqJrW TxubFzfrWgAFx8RoFGphDOvWnDZgUVvGGwBJxclaPNio+C66ih+Vi6E6Kb70arUI debhQ47w2yf6VH24ijySL9JxTnqFzpNxUpvXLk2Ejm5OMPnOVGCFVQKgTnLQlxMV AjLNdpkZgsR3EjkpoOMHkN6ePCyue5Qn4cmZT01OGtfHy0hboxYvrDheEjxcdG0= =zv3n -----END PGP SIGNATURE----- --------------enig6E8A5D7E21F4C0A69AAA0848-- From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 21:21:30 2012 Received: (at 12339) by debbugs.gnu.org; 13 Sep 2012 01:21:31 +0000 Received: from localhost ([127.0.0.1]:58139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBy7W-0006U0-Hb for submit@debbugs.gnu.org; Wed, 12 Sep 2012 21:21:30 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:33468 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBy7P-0006Tp-Fw for 12339@debbugs.gnu.org; Wed, 12 Sep 2012 21:21:28 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8D1KV1a831779; Wed, 12 Sep 2012 18:20:33 -0700 Message-ID: <505134DF.9050300@tlinx.org> Date: Wed, 12 Sep 2012 18:20:31 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: Eric Blake , "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> Subject: Re: bug#12339: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) References: <5043FA91.9070703@tlinx.org> <50511207.2010108@tlinx.org> <505128B2.6000008@redhat.com> In-Reply-To: <505128B2.6000008@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) Eric Blake wrote: > On 09/12/2012 04:51 PM, Linda Walsh wrote: >> I hope to prove the subject convincingly in the following sections, If >> you can, reading this in the original HTML might be useful, as I don't >> know it will end up when converted to text. > > the mail engines sripped it to > plain text before it ever hit the list or the online bug report: > http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12339#239 ---- Doesn't look like it. I sent it in plain and HTML, and it displays the plaintext as formatted by Thunderbird, by default, and has a link to the second part where it has stored the original. Seems your db-bug report engine is smarter than you give it credit for -- that and my deliberately including a plaintext version that would try to represent the formatting as closely as possible. > So please bear with me if my inability to see your intended markup means > that I misinterpret your intent. --- If you want to see the html copy, it kept it at: http://debbugs.gnu.org/cgi/bugreport.cgi?msg=239;att=1;bug=12339. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 12 22:50:01 2012 Received: (at 12339) by debbugs.gnu.org; 13 Sep 2012 02:50:01 +0000 Received: from localhost ([127.0.0.1]:58275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBzVA-00005M-Sk for submit@debbugs.gnu.org; Wed, 12 Sep 2012 22:50:01 -0400 Received: from ishtar.tlinx.org ([173.164.175.65]:36418 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TBzV8-00005C-5L for 12339@debbugs.gnu.org; Wed, 12 Sep 2012 22:49:59 -0400 Received: from [192.168.3.12] (Athenae [192.168.3.12]) by Ishtar.sc.tlinx.org (8.14.5/8.14.4/SuSE Linux 0.8) with ESMTP id q8D2n5AZ842743 for <12339@debbugs.gnu.org>; Wed, 12 Sep 2012 19:49:08 -0700 Message-ID: <505149A1.1060007@tlinx.org> Date: Wed, 12 Sep 2012 19:49:05 -0700 From: Linda Walsh User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: "12339@debbugs.gnu.org" <12339@debbugs.gnu.org> Subject: Re: bug#12339: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) References: <5043FA91.9070703@tlinx.org> <50511207.2010108@tlinx.org> <505128B2.6000008@redhat.com> In-Reply-To: <505128B2.6000008@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 12339 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) Eric Blake wrote: > They are also well-defined terms in the POSIX standard. > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_40 > http://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html > http://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html > > Let's look at some different "Cases" of sample pathnames (skipping >> the easy ones, given the audience): >> >> Case A: "/" What is the dirname and what is the basename? >> >> Answer: and . > > Unfortunately, your interpretation is not consistent with the POSIX > definitions. The POSIX-mandated answer is a dirname of '/' and a > basename of '/'. Additionally, this particular file name is always a > directory. ---- I admit, you are half right. It says to return a directory indicator for a basename ... which I find absurd, however, it says to strip off the '/' for a dirname and only return the parent. Specifically: The dirname() function shall take a pointer to a character string that contains a pathname, and return a pointer to a string that is a pathname of the parent directory of that file. Trailing '/' characters in the path are not counted as part of the path. So even if the parent was "/", it is not to count as part of the path. There is no place on disk or in the the OS that calls the root dir "/", a rootfs is mounted at /, but that's not the name of the rootfs. > >> Case B: "ENTRY/" What is the dirname and what is the basename? >> >> Answer: Dirname="ENTRY", basename=. (Explanation seems unnecessary). > > Unfortunately, your interpretation is not consistent with the POSIX > definitions. The POSIX-mandated answer is a dirname of '.' ---- But that is semantically incorrect. They can define it that way, but semantically that isn't consistent with existing implementation. Example: Is "find" POSIX compatible? Typing "find DIR", doesn't yield output of ./dir -- yet that would be required if it followed those rules. >> Case C: "ENTRY" Dir and Basenames? >> >> Answer: it depends on context and what it really is. > > Unfortunately, your interpretation is not consistent with the POSIX > definitions. The POSIX-mandated answer is a dirname of '.' and a > basename of 'ENTRY'. But you are correct that it may or may not be a > directory. --- yet it is consistent with current implementation and POSIX is meant to be _descriptive_ not _prescriptive_, therefore it is POSIX that is not matching implementation. People need to read the preamble to POSIX. If the implementation they have doesn't match what POSIX describes, then POSIX has err'ed. >> Whether or not 'ENTRY' is a basename or a dirname depends on whether or >> not 'ENTRY' is a directory. > > Rather, the POSIX definition states that 'ENTRY' is a basename because > it is the last non-slash component of the overall string, after > stripping any trailing slashes. Remember, a directory is ALSO a file, ---- It can only be treated as a file when it is empty. then one can issue a single command for it's removal. Otherwise, a directory is more than just a file. > just like a symlink or a socket or a character device is also a file. > The term basename applies to any file, not just non-directory files. ---- This > >> Example. In it's default mode rm removes only files. > > Correction - in its default mode, rm removes regular files, symlinks, > fifos, block devices, character devices, socket files, and any other > implementation extension file types, but has special case treatment of > directory files. ----- One just said a symlink, socket or char device are files... so what is being corrected by by the above statement? AFAIK, I'm I'm differentiating between files entries in a directory and directory entries that contain other files. If the directory contains nothing and is empty -- it can, 'effectively', be treated as a file, and removed with it's type-specific-removal operation. Directories need more than simple unlinking because they are not simply 'entries', they are objects with references to other objects (including itself). Those need special handling to be deconstructed by the OS. They are not files that the user has control over nor that POSIX should be trying to claim control of. > this special case treatment is mandated by POSIX, to match historical practice. --- Not exactly true. It's because it is mandated OS function and POSIX is descriptive. (which could be two ways of saying the same thing, but it is not solely for historical benefit). > >> "rm a b c ENTRY d" -- rm expects all entries to to simple basenames. If >> it encounters a dirname, it issues an error and refuses to operate on it. > > Correcting your terminology: > If it encounters a *directory*, it issues an error and refuses to > operate on it. --- If it encounters a 'name' that is a directory name. That's what I am calling a dirname -- because that is what it *is*. It's descriptive of it's function. POSIX is suppose to be descriptive. If it is not, then it is failing. >> In it's recursive mode, rm will accept basenames and dirnames. It will >> inspect each entry to determine if it is a file (basename) or a >> dir(dirname). > Again correcting your terminology: my terminology is accurate. It doesn't accept directories. It accepts NAMES of directories. Don't confuse the name for the object. We have names for objects, but the name is not the object. The directory is a container. It has a name -- often called a directory name or dirname for short. But that's just common sense. Yet you are saying under POSIX, normal common sense and literal definitions do not apply. That's not being descriptive. > rm will accept directories in addition to other file types. --- No, it will accept directory names and handle them separately and differently from every other entry in a 'dir'. >> Only after the contents have been removed is it no longer a dirpath -- > > This statement makes no sense in light of POSIX terminology. --- POSIX is failing at it's job of being descriptive. I was careful in choosing my words in writing the previous document, as they were descriptively taken from their function in the OS. By using arbitrary, POSiXELLIAN terminology you start being unable to describe what is and you start to hinder communication. This is usually done by authoritarian entities to serve their own ends. >> There are 2 entries not covered usually covered by security policies, as >> they are not discretionary entries -- they are mandatory components of >> the OS, namely "." and "..". > > Actually, believe it or not, '.' and '..' are NOT mandatory directory > entries in POSIX. ---- I didn't say it was mandatory in POSIX, just the OS -- that POSIX isn't following its descriptive mandate is unsurprising. >> As POSIX is a computer portability standard, one would imagine that they >> know the difference between dirnames and basenames > > Yes, POSIX has a self-consistent definition of those terms. ---- Yes... a self, internally, *Orwellian*, *new-speak* definition. > No, that is not a consistent statement in light of the POSIX definition > of the terms. --- In which they attempt to obfuscate function and thus, are demonstrably not following their intended mission of being descriptive. This brings into question whether or not they are *really* POSIX terms, or terms created and made up by opportunists who see POSIX as a way to create and enforce their standard. But clearly, they do so by violating POSIX's original charter/mission statement. Doesn't that mean their statements and words are not POSIX compliant and can't be considered as POSIX? You see, that's where I break with POSIX -- I was all for POSIX compliance as a descriptive standard... but as soon as they changed from descriptive to prescriptive, they became 'not-POSIX' anymore. From debbugs-submit-bounces@debbugs.gnu.org Fri Jan 18 04:29:36 2019 Received: (at 12339) by debbugs.gnu.org; 18 Jan 2019 09:29:36 +0000 Received: from localhost ([127.0.0.1]:35668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gkQT2-0007VT-25 for submit@debbugs.gnu.org; Fri, 18 Jan 2019 04:29:36 -0500 Received: from mail-pf1-f180.google.com ([209.85.210.180]:36325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gkQT0-0007V8-Ij; Fri, 18 Jan 2019 04:29:35 -0500 Received: by mail-pf1-f180.google.com with SMTP id b85so6322477pfc.3; Fri, 18 Jan 2019 01:29:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=fkiCxvQFFrHXSdZUcZUF9ox8KUuFVS3fmNY7ElAIL8g=; b=F/8oQm56ybqoPopn1Vecl2WQ+A0vMn40t+FoEKGq0+XC5LCPpJKBvcktlTwjkII2hH zJAtfzYkEFnM1DdwzRKa2sRufPPUwI7U1iZlBQt98iDp0s1yemMAZ9f+tvO5D+hDBV9g unv8tx/gIRy5yrGDm2HeybWWzxFGXmcauEAN6IGkcfqEHbMrPDYCdkRjGP0bllBU3505 ZN0pTuYZDRnSBi0lt2gP2puI1OJFLsJtbhB69aVATfju5/LVFCmyMq+SQLyQnKXH3iRa 9IgWHrq8EgeQY0eEwUG+Rfz9lsb5nHG6MWXLD3paPCwXdxO5jv7VZoKDT6Mr3byAoZzo hr6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fkiCxvQFFrHXSdZUcZUF9ox8KUuFVS3fmNY7ElAIL8g=; b=rhwpnj4HvRqXXsd+JGrMrECpAMwGcTkW0lkCgwFhmwiThxtokQ1/dQ1uRT5CbQVbeO vYq+uV7jKTlyXg3H0KBsKi1QqSAP+KgRtL3mVkU3Fb0xUziG53kaEsdnxYlxQh5Mstkn IDbk8X5sAFNO1QZtV+ClA1gdYyl1kdASWAQLn9LH1Bt7LxDldNM+kA+c1s3NCLYUaC4Y zcpXSQtEo0LJv0ZQV4f8MO/fG42opvcHZtl4TBpbl/VbVLLYjpyX+1OkX5n3nNuxzOLL 88uWm5prj/Uc6WWeabNox0BleTwl3/MdTvAul+jvQedeE/woompt1tyUbPTXRbbwXXNx aKLA== X-Gm-Message-State: AJcUukfcpFl9QdiHFM2N1A5aGFu3nHmfF0pyvQsz5wBwQ3n6mbCylMjP DUS99ZuwkVbnC+m+Loy50KEOFYF8nY0= X-Google-Smtp-Source: ALg8bN5XXAR6kCRqfVkaE5E9uxNgsKSI/EXpvnVjVUw40rliI7w9sVWYjFfK3OV6XJfCoQO5Gi9S/w== X-Received: by 2002:a63:4f20:: with SMTP id d32mr9803438pgb.47.1547803767377; Fri, 18 Jan 2019 01:29:27 -0800 (PST) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id o13sm6157962pfk.57.2019.01.18.01.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 01:29:26 -0800 (PST) Subject: Re: bug#12339: Gnu rm, changed only recently (4-5 years), and didn't follow letter of posix...(statement follows) To: Linda Walsh , 12339@debbugs.gnu.org References: <5043FA91.9070703@tlinx.org> <50511207.2010108@tlinx.org> <505128B2.6000008@redhat.com> <505149A1.1060007@tlinx.org> From: Assaf Gordon Message-ID: Date: Fri, 18 Jan 2019 02:29:24 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <505149A1.1060007@tlinx.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 12339 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.0 (-) close 12339 stop (triaging old bugs) Hello, This long and winding thread covers several topics relating to rm(1), historical unix and POSIX compatibility (and a bugfix or two in the mix). An enlightening read for those interested... ( https://bugs.gnu.org/12339 ) But the bottom line is: rm -rf . will not delete the content of the current directory (while keeping the directory itself) and that is not likely to change. Two suggested alternatives: find . -delete rm -rf * .[!.] .??* As such, and with no more comments in 6 years, I'm closing this bug. PLEASE do not reply to this thread. If there are other relevant issues (that have not been discussed elsewhere, and have not been previously rejected), please start a new thread by emailing coreutils@gnu.org . regards, - assaf From unknown Tue Aug 19 05:10:27 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, 15 Feb 2019 12: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