* Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set [not found] ` <20170911150740.pz7fudj5lsflrmtk@tarpaulin.shahaf.local2> @ 2017-09-11 15:19 ` Daniel Shahaf 2017-09-11 15:23 ` Peter Stephenson 0 siblings, 1 reply; 5+ messages in thread From: Daniel Shahaf @ 2017-09-11 15:19 UTC (permalink / raw) To: zsh-workers; +Cc: 875460-forwarded, Maxime “pep” Buquet Forwarding from Debian: Daniel Shahaf wrote on Mon, 11 Sep 2017 15:07 +0000: > $ zsh -f > % cd $(mktemp -d) > % touch ./foo ./.bar > % rm * > zsh: sure you want to delete all 2 files in /tmp/tmp.65xnqgzMAY [yn]? y > % > % ls -A > .bar > % echo $ZSH_PATCHLEVEL > zsh-5.4.2-1-gab6ac7313 The problem is that it says "2 files" but only one file is deleted. The impedance mismatch is that checkrmall() calls zreaddir(..., unset(GLOBDOTS)), but the second actual argument to zreaddir() governs whether the dot and dot-dot entries would be excluded. Instead, checkrmall() should pass true for the second argument of zreaddir(), and dotfiles should be ignored by some other means when ignoredots is true. (I've just added a docstring to zreaddir() to close the barn door.) 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? Cheers, Daniel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set 2017-09-11 15:19 ` zsh: RM_STAR warning counts files as though DOT_GLOB is set Daniel Shahaf @ 2017-09-11 15:23 ` Peter Stephenson 2017-09-11 15:31 ` Bart Schaefer 0 siblings, 1 reply; 5+ messages in thread From: Peter Stephenson @ 2017-09-11 15:23 UTC (permalink / raw) To: zsh-workers; +Cc: 875460-forwarded, Maxime “pep” Buquet On Mon, 11 Sep 2017 15:19:15 +0000 Daniel Shahaf <danielsh@apache.org> 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. I haven't looked, but probably the stuff above it gradually expanded to make this case logically redundant, unless there's a mismatch. pws ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set 2017-09-11 15:23 ` Peter Stephenson @ 2017-09-11 15:31 ` Bart Schaefer 2017-09-11 15:41 ` Daniel Shahaf 0 siblings, 1 reply; 5+ messages in thread From: Bart Schaefer @ 2017-09-11 15:31 UTC (permalink / raw) To: zsh-workers On Mon, Sep 11, 2017 at 8:23 AM, Peter Stephenson <p.stephenson@samsung.com> wrote: > On Mon, 11 Sep 2017 15:19:15 +0000 > Daniel Shahaf <danielsh@apache.org> 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". ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set 2017-09-11 15:31 ` Bart Schaefer @ 2017-09-11 15:41 ` Daniel Shahaf 2017-09-15 5:35 ` Bart Schaefer 0 siblings, 1 reply; 5+ messages in thread From: Daniel Shahaf @ 2017-09-11 15:41 UTC (permalink / raw) To: zsh-workers Bart Schaefer wrote on Mon, 11 Sep 2017 08:31 -0700: > On Mon, Sep 11, 2017 at 8:23 AM, Peter Stephenson > <p.stephenson@samsung.com> wrote: > > On Mon, 11 Sep 2017 15:19:15 +0000 > > Daniel Shahaf <danielsh@apache.org> 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: zsh: RM_STAR warning counts files as though DOT_GLOB is set 2017-09-11 15:41 ` Daniel Shahaf @ 2017-09-15 5:35 ` Bart Schaefer 0 siblings, 0 replies; 5+ messages in thread From: Bart Schaefer @ 2017-09-15 5:35 UTC (permalink / raw) To: zsh-workers On Sep 11, 3:41pm, Daniel Shahaf wrote: } } 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". IIRC this was discussed at the time, and the conclusion was that the race condition is acceptable as long as the user is prompted and must answer yes -- the count needn't be accurate when non-zero, it just mustn't be skipped when zero. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-15 5:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20170911143436.GB1960@caska> [not found] ` <20170911150740.pz7fudj5lsflrmtk@tarpaulin.shahaf.local2> 2017-09-11 15:19 ` zsh: RM_STAR warning counts files as though DOT_GLOB is set Daniel Shahaf 2017-09-11 15:23 ` Peter Stephenson 2017-09-11 15:31 ` Bart Schaefer 2017-09-11 15:41 ` Daniel Shahaf 2017-09-15 5:35 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).