Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Any way to allow clobbering empty files when noclobber is set?

> On 04 June 2020 at 06:06 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Wed, Jun 3, 2020 at 5:05 AM Peter Stephenson
> <p.stephenson@xxxxxxxxxxx> wrote:
> >
> > Martin Tournoij wrote:
> > > I rather miss though: the 'notempty' option in 'noclobber'.
> >
> > This isn't actually hard to implement.  What does everyone else think?
> Gmail thinks ".dif" is a spreadsheet, and MacOS thinks it's a video.

And, obviously, as a mere user, you're not allowed to treat it any
differently without actually downloading it...
> More seriously ... what, if any, effect ought this have on "command >>
> nonexistent" ?

I couldn't see any direct relevance, but there may be some overlap
I've missed.
> 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?

I'm not entirely sure if we get quite the same behaviour if we do
that.  At the least we'd need to open the existing file without
truncating (then either close it or leave it open for writing
if it was already empty).  Unless there's a security aspect to this,
with there already being an endless number of things to go wrong if
files are actively changing under you, I'd be inclined just to keep
it simple.  Happy to hear a knockout argument the other way.


Messages sorted by: Reverse Date, Date, Thread, Author