Zsh Mailing List Archive
Messages sorted by:
Re: Any way to allow clobbering empty files when noclobber is set?
- X-seq: zsh-workers 45981
- 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: Fri, 5 Jun 2020 06:38:46 +0200
- Cc: "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>
On Fri, Jun 5, 2020 at 4:07 AM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> 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 &
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.
Messages sorted by: