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 13751 invoked from network); 4 Jun 2020 06:48:39 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 4 Jun 2020 06:48:39 -0000 Received: (qmail 17374 invoked by alias); 4 Jun 2020 06:48:29 -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: 45965 Received: (qmail 21877 invoked by uid 1010); 4 Jun 2020 06:48:29 -0000 X-Qmail-Scanner-Diagnostics: from out4-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(66.111.4.28):SA:0(-2.7/5.0):. Processed in 4.124182 secs); 04 Jun 2020 06:48:29 -0000 X-Envelope-From: martin@arp242.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 66.111.4.28 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudegtddgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderredtnecuhfhrohhmpedfofgrrhhtihhnucfvohhurhhnohhijhdfuceomhgrrhht ihhnsegrrhhpvdegvddrnhgvtheqnecuggftrfgrthhtvghrnhepgeefudffgefgvdfhff duudffieevgfelveduudefhfeijeduffekjeeileetgffgnecuffhomhgrihhnpehgihht hhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehmrghrthhinhesrghrphdvgedvrdhnvght X-ME-Proxy: X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-dev0-519-g0f677ba-fm-20200601.001-g0f677ba6 Mime-Version: 1.0 Message-Id: <5a99c7b5-dc31-4699-9587-5adabd8b035b@www.fastmail.com> In-Reply-To: References: <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> Date: Thu, 04 Jun 2020 14:47:50 +0800 From: "Martin Tournoij" To: zsh-workers@zsh.org Subject: Re: Any way to allow clobbering empty files when noclobber is set? Content-Type: text/plain On Thu, Jun 4, 2020, at 13:06, Bart Schaefer wrote: > More seriously ... what, if any, effect ought this have on "command >> > nonexistent" ? Probably none? > I'm not familiar with the tcsh variation of this. Does it matter if > the file is a symlink? > > Should this be done with open()-then-fstat() as is done for > non-regular files instead of stat()-then-open(), to avoid race > conditions? tcsh does a stat() to check the file permissions and size, and then xcreat()s (some wrapper around creat()?) it if it all looks good; see: https://github.com/tcsh-org/tcsh/commit/cc952ed342f6460a33fa77111c4edfcd915ce9b5#diff-1c39f18ef0f96621a9b743b6e4400fabR984 You're right that this is subject to race conditions since there might be data written to the file in between the 2 calls. I'm not entirely sure how realistic this scenario is though?