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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13927 invoked from network); 5 Jun 2020 04:39:40 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 5 Jun 2020 04:39:40 -0000 Received: (qmail 19402 invoked by alias); 5 Jun 2020 04:39:33 -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: 45981 Received: (qmail 5693 invoked by uid 1010); 5 Jun 2020 04:39:33 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f49.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.166.49):SA:0(-2.0/5.0):. Processed in 1.516618 secs); 05 Jun 2020 04:39:33 -0000 X-Envelope-From: roman.perepelitsa@gmail.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.166.49 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; bh=EjYDYxvzJwA4AoKUM+ZHdzdGot1LauYaCxBGp5fxbyk=; b=sBag5kkKff1dfwRZEHKO6DbwgXJ9PJMWStuva6vDZuQz8zWHFwD4H34Ek3M1YlxMJQ c8f7Bnbxb/d9SyLrxyeR83M+xciw0tyiWjA3On5TYuXKiM431k+T7ybypIyr7HU6YYj7 l7VAUELM21qZ6AsKF9Xg0MDMmZNwKNdwvA1q3T5gxbOXrGrozr9s4sDsTR3jO3ohmmum kWjtiho1luPIyBu6yNVHuEYk/Cdia+Il094CAv/gOFwGJe2RQlucwDlH4aykMWmqIjnV Q0+Z3wnvGiKIlXiHqnyfwW8q3m7KYzEnQ+zsMZByYwOM08OQhO2L+CdlCjSB+hFo+21e Qf+g== X-Gm-Message-State: AOAM531XxgnfEd6aeiE5nSrR+cyIAF7XdhzNNt/UG/PCZPUuook+wXVf lq89warU0hy2uaGbvVajR7JUequSIJEKO/+xdhbxDw== X-Google-Smtp-Source: ABdhPJyZAnRrie8Dj/wkJS5TDF1sUzQxNG2auH+qFcnfXegtYV2z0EDgYlGFCLi0v8rXyvaPxr9R6gqUkZS1Fw5bNXk= X-Received: by 2002:a5d:87c4:: with SMTP id q4mr6976171ios.169.1591331938119; Thu, 04 Jun 2020 21:38:58 -0700 (PDT) MIME-Version: 1.0 References: <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <20200605020748.635b9bb3@tarpaulin.shahaf.local2> In-Reply-To: <20200605020748.635b9bb3@tarpaulin.shahaf.local2> From: Roman Perepelitsa Date: Fri, 5 Jun 2020 06:38:46 +0200 Message-ID: Subject: Re: Any way to allow clobbering empty files when noclobber is set? To: Daniel Shahaf Cc: "zsh-workers@zsh.org" , Martin Tournoij Content-Type: text/plain; charset="UTF-8" On Fri, Jun 5, 2020 at 4:07 AM Daniel Shahaf wrote: > > Roman Perepelitsa wrote on Thu, 04 Jun 2020 07:41 +0200: > > > Or how to implement clobber-if-empty without ever clobbering non-empty > > files? > > By using a non-clobbering open(), then calling fstat() on the open fd. > If it's zero length, just carry on. If it's not zero length, close() > it and report an error. Consider the following program: write() print -rn -- $1 rm -f foo write hello >foo & write bye >foo & wait With regular no_clobber it has the following guarantees: 1. `write` is executed exactly once 2. once `wait` completes, `foo` contains either "hello" or "bye" Is there a way to provide these guarantees with clobber_empty? (2) is especially important. Seeing "byelo" or "hellobye" in `foo` would be quite confusing. It would look like clobbering. Roman.