Zsh Mailing List Archive
Messages sorted by:
Re: Any way to allow clobbering empty files when noclobber is set?
- X-seq: zsh-workers 45997
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Subject: Re: Any way to allow clobbering empty files when noclobber is set?
- Date: Sat, 6 Jun 2020 08:25:10 +0200
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>, Martin Tournoij <martin@xxxxxxxxxx>
- In-reply-to: <email@example.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20200603020919eucas1p13e26ebcbb335784d14bfb97b137f385a@eucas1p1.samsung.com> <email@example.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <CAH+w=7YpQ3CcsMhAvztGHx19FnALBV349RAz4p8iuB+_8AnsxQ@mail.gmail.com> <CAN=4vMqBCZqD04QO-hw0DwipmCVkdq+QNOEGNaSEfNxyRBqiiw@mail.gmail.com> <firstname.lastname@example.org> <CAN=4vMoC8aNBz=ZAW-BdA9W6MaBXN3SNBPpZZQobVRwjUg2wGQ@mail.gmail.com> <CAH+w=7ZHapcvCZ=QmV2QEBxi1HGwfKOd4dJ47Ndi+5R-V2VDSg@mail.gmail.com> <email@example.com>
On Sat, Jun 6, 2020 at 6:56 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> > On Thu, Jun 4, 2020 at 9:39 PM Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> > Is there a way to provide these guarantees with clobber_empty?
> I don't understand the question, really.
If someone writes "hello" and "bye" to the same file with no_clobber
and clobber_empty, and no error occurs (apart from no_clobber kicking
in and refusing to clobber), what can be the content of the file in a
conformant zsh implementation? I think providing an answer to this
question is important. Without it it's unclear what no_clobber with
If writes happen sequentially, the file will contain either "hello" or
"bye". It cannot contain anything else. If the same guarantee could be
provided for concurrent writes, that would be ideal. I don't think
it's possible on all systems that zsh targets but maybe I'm wrong. On
some systems there might be no better answer than "the content of the
file is unspecified". This can be counterintuitive. Seeing "byelo" or
"hellobye" in the file one could reasonably assume that "hello" was
clobbered by "bye" despite options that on the surface disallow
clobbering non-empty files.
On Sat, Jun 6, 2020 at 3:42 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> I think the answer is that #2 can be guaranteed if and only if
> fcntl()-based locking can be applied, or some equivalent kernel
> mechanism such that no more than closing of the (last dup of the)
> descriptor is necessary to release the lock.
Nod. It would also guarantee #1.
Messages sorted by: