Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Any way to allow clobbering empty files when noclobber is set?
- X-seq: zsh-workers 45965
- From: "Martin Tournoij" <martin@xxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Any way to allow clobbering empty files when noclobber is set?
- Date: Thu, 04 Jun 2020 14:47:50 +0800
- In-reply-to: <CAH+w=7YpQ3CcsMhAvztGHx19FnALBV349RAz4p8iuB+_8AnsxQ@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20200603020919eucas1p13e26ebcbb335784d14bfb97b137f385a@eucas1p1.samsung.com> <89aed74d-db7b-47ad-b218-8158838049e9@www.fastmail.com> <94e73ebcf39d4d3f9c7ae257b1d75d16@CAMSVWEXC01.scsc.local> <CAH+w=7YpQ3CcsMhAvztGHx19FnALBV349RAz4p8iuB+_8AnsxQ@mail.gmail.com>
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?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author