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 13537 invoked from network); 6 Jun 2020 01:08:46 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 6 Jun 2020 01:08:46 -0000 Received: (qmail 21493 invoked by alias); 6 Jun 2020 01:08:41 -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: 45991 Received: (qmail 2353 invoked by uid 1010); 6 Jun 2020 01:08:41 -0000 X-Qmail-Scanner-Diagnostics: from mail-ot1-f65.google.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(209.85.210.65):SA:0(-1.9/5.0):. Processed in 1.748383 secs); 06 Jun 2020 01:08:41 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.210.65 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6Kvl5g1pMtQzhWec5iYYF1HYxyFHCOWO0K5Jy9fXeqE=; b=dvM5tWgpQc2HCo8N6+qhL2QJf5V3g6lgEeERptpRhAU8vgHWaA3StR+uQUe2PcRx2D YKyFJb0KjQPUt0SrxMWaG0NMxxeiVLdKOKKb4ime6LgfmAIJT35baV0SDqCsBncrbw1g RK0EOxFPokkR4AYJ1Mv4eLa5hR+f+yx/kEz7nXFfM+M8H5e8vv/K7fRiBTDdgSF0H89G tJ+O499Ag+Oyrw+Ij+cIoHmYbs6Sa9AazzxghxEdnhdH0mc+y3Hm/6NcOSWXN2WWmyuC Q3bjnH40KGJjGQHHu9y+UjNHJdUlJOE2HYEDTPEyQ2yJvqYn4kpqL1soo2YFAwwiq1gi +p8w== X-Gm-Message-State: AOAM533F++9u1tk4Ae4ATGaWV0lazGQURvYRJ5bdwRbteFgUHjTRhvrb +xOZFuA8erFH51YUz87YK/fSNZblQX4vfgTMqLJ2B73tqdQ= X-Google-Smtp-Source: ABdhPJygo6zlOlDcus8wOvfnYnF6tmMk68Mjq8JBkmuCrDhEtp6urR1QfhhOR3RtYFDoJWVjq/4AKeVb5glIOtgz9DQ= X-Received: by 2002:a9d:6c4e:: with SMTP id g14mr6474365otq.229.1591405685271; Fri, 05 Jun 2020 18:08:05 -0700 (PDT) MIME-Version: 1.0 References: <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <20200604014850.52d241bd@tarpaulin.shahaf.local2> <20200605031013.16a36d31@tarpaulin.shahaf.local2> In-Reply-To: <20200605031013.16a36d31@tarpaulin.shahaf.local2> From: Bart Schaefer Date: Fri, 5 Jun 2020 18:07:54 -0700 Message-ID: Subject: Re: Any way to allow clobbering empty files when noclobber is set? To: "zsh-workers@zsh.org" Cc: Martin Tournoij Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable (Martin, if you are no longer interested in these side discussions, we can stop Cc'ing you.) On Thu, Jun 4, 2020 at 8:10 PM Daniel Shahaf wrote= : > > Bart Schaefer wrote on Wed, 03 Jun 2020 22:00 -0700: > > Fair enough, although (silly example) "false > empty" would remove the > > file? > > Depends on whether ./empty was created by the redirection or not. 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 That seems at least impractical, especially the last one. And what happens in the case of rename? > 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? Open could fail because of file permissions. Unlink depends only on directory permissions. > Okay. Is there a case where leaving around an empty file is worse than > removing it? IMO your examples are all too specific to warrant a generalized change in behavior of redirections.