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

Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set



Bart Schaefer wrote on Mon, 11 Sep 2017 08:31 -0700:
> On Mon, Sep 11, 2017 at 8:23 AM, Peter Stephenson
> <p.stephenson@xxxxxxxxxxx> wrote:
> > On Mon, 11 Sep 2017 15:19:15 +0000
> > Daniel Shahaf <danielsh@xxxxxxxxxx> wrote:
> >> I don't understand the last branch of the if/else in that function: it
> >> seems to prompt "... delete all the files ..." when count == 0?
> >
> > Apparently, yes.  I think it's just covering the bases.
> 
> The issue here, as I recall, is that it's possible to have:
> 1 "rm *" is issued
> 2 chkrmall() finds no files in the directory
> 3 some external process creates a file
> 4 "rm *" is executed
> 5 the file created at (3) is silently deleted
> 
> So we would need either to avoid re-expanding "*" after chkrmall(), or
> treat "found no files" as "user answered no".

Good catch.

The warning messages emitted by the "if" and "else if" branches are all
susceptible to this race condition.  They were all added in 37946 in
order to "make [the] warnings more informative".

Simply reverting 37946 would resolve both the OP's problem and this race
condition. (Just stating a fact; maybe there are other/better solutions)

Cheers,

Daniel



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