From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4106 invoked from network); 6 Jun 2020 04:48:51 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 6 Jun 2020 04:48:51 -0000 Received: (qmail 6070 invoked by alias); 6 Jun 2020 04:48:45 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45994 Received: (qmail 22800 invoked by uid 1010); 6 Jun 2020 04:48:45 -0000 X-Qmail-Scanner-Diagnostics: from wout4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25828. spamassassin: 3.4.4. Clear:RC:0(64.147.123.20):SA:0(-2.6/5.0):. Processed in 0.727363 secs); 06 Jun 2020 04:48:45 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeggedgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfgjfhfogggtgfesthhqtddtredtjeenucfhrhhomhepffgrnhhi vghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvgeqne cuggftrfgrthhtvghrnhephfdtteefheevuedthedutdeifeegteettdejtdffheduieei jeelteetkeduteehnecukfhppeejledrudejiedrfeelrdeileenucevlhhushhtvghruf hiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhh rghhrghfrdhnrghmvg X-ME-Proxy: Date: Sat, 6 Jun 2020 04:48:08 +0000 From: Daniel Shahaf To: Bart Schaefer Cc: "zsh-workers@zsh.org" , Martin Tournoij Subject: Re: Any way to allow clobbering empty files when noclobber is set? Message-ID: <20200606044808.59509bdf@tarpaulin.shahaf.local2> In-Reply-To: References: <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <20200604014850.52d241bd@tarpaulin.shahaf.local2> <20200605031013.16a36d31@tarpaulin.shahaf.local2> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Bart Schaefer wrote on Fri, 05 Jun 2020 18:07 -0700: > (Martin, if you are no longer interested in these side discussions, we > can stop Cc'ing you.) >=20 > On Thu, Jun 4, 2020 at 8:10 PM Daniel Shahaf wro= te: > > > > Bart Schaefer wrote on Wed, 03 Jun 2020 22:00 -0700: =20 > > > Fair enough, although (silly example) "false > empty" would remove the > > > file? =20 > > > > Depends on whether ./empty was created by the redirection or not. =20 >=20 > Hm. That means that the following must all be preserved (in the > parent shell, so fails for "exec command > file") all the way from the > redirection event to the completion of the command: > - whether the descriptor resulted from redirection > - what kind of redirection operator was used > - whether the appropriate clobber-related option was set at the time > - how to identify the file we opened, in case something else renamed > or removed it, and created another one of the same name in the > meantime >=20 > That seems at least impractical, especially the last one. It'll just be a couple of local variables on the C stack, won't it? For the last bullet, I suppose we could save the inode number (and device number), but as I wrote in workers/45977, I don't see a way to avoid a race condition. > And what happens in the case of rename? If the file has been renamed before we get around to unlink it, then we won't unlink it. We won't have a choice. > > Besides, if the redirection failed =E2=80=94 I assume you mean the open= (2) > > failed =E2=80=94 then isn't the unlink likely to fail as well? =20 >=20 > Open could fail because of file permissions. Unlink depends only on > directory permissions. >=20 Well, yes, but usually, if you don't have permission to read a file, in practice you won't have permission to delete it either. > > Okay. Is there a case where leaving around an empty file is worse than > > removing it? =20 >=20 > IMO your examples are all too specific to warrant a generalized change > in behavior of redirections. Fair enough. As I said, just brainstorming. Cheers, Daniel