On 2022-06-14, Dan Espen <
[email protected]> wrote:
Kaz Kylheku <[email protected]> writes:
The problem with --ignore-fail-on-non-empty that it's five words
long.
Snipped the rest of the post where you didn't even try to prove that 5
words is a problem. As it is, the rarely used option explains itself.
It doesn't explain itself.
If I encountered it in a script I'd know exactly what it does.
I had to look it up and experiment with it, and also rely on other documentation (POSIX). My first blind guess was: does it actually delete
the nonempty directory, like rm -r? But no, that couldn't be it;
that's significantly more than what "ignore" means.
So my next suspicion was: ok, so if ignoring that situation is
not the default behavior, it might be that rmdir *heeds* the situation
somehow. Maybe it's deleting the directories in left-to-right
order and then failing on the first nonempty directory,
so the rest are unprocessed.
But in fact, ignore just means "ignore for the purposes of calculating
the termination status", not for the purposes of any action.
To be sure about this, I had to experiment. Neither the man nor the info
page explains what it means to ignore or not to ignore the error.
Before that, I also looked at the POSIX documentation, which which
assures us that rmdir invokes the rmdir system call for each argument.
The POSIX documentation also has this:
EXIT STATUS:
The following exit values shall be returned:
0
Each directory entry specified by a dir operand was removed
successfully.
>0
An error occurred.
We know that since the rmdir system call is used, ENOTEMPTY is an error;
so we know that if one or more directories were not deleted due to not
being empty, and all others were deleted, there will be a failed status.
The GNU documentation says only this (in the info page, not the man
page):
An exit status of zero indicates success, and a nonzero value
indicates failure.
which is just teaching the reader how exist status works in a POSIX-like system, not what it means for this particular command.
After looking at the POSIX documentation, I inferred that "ignore" must
just mean mean not to to include that situation in the exit status,
after which a quick experiment confirmed it.
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)