Show quoted text>>>>> On Mon, 20 Jul 2015 05:42:48 -0400, "Richard Elberger via RT" <bug-File-Path@rt.cpan.org> said:
Show quoted text > I don't mean to hijack your conversation with Jim, but in the
> context of that unit test the latter is certainly more precise. In a
> clean environment, that line doesn't look to be necessary. But if
> someone is running the test over and over again, then the directory
> could exist if the script dies in the middle and doesn't run the
> last line. So... there should be a condition.
Thank you for chiming in.
Show quoted text > Simply speaking, we are talking about the principle of least
> surprise (especially for the general user). The documentation
> states:
Show quoted text > The "remove_tree" function deletes the given directories and any files
> and subdirectories they might contain ...
The question boils down to: when the documentation of old code does not
perfectly well match the implementation, what should be changed, the
documentation or the code?
This can often be argued both ways. If the code is crap, fix it. If the
code is good, fix the documentation. If the code has a record of keeping
people happy for over 15 years, fix the docs. I'm sure not everybody was
always happy about it, but if there is an itch to change code that old,
one probably has to do some homework of arguing before editing the code.
Show quoted text > However the documentation continues:
Show quoted text > .... much like the Unix command "rm -r" or the Windows
> commands "rmdir /s" and "rd /s".
The docs are vague, fixing them is not a bad idea. Changing the code is.
Show quoted text > Which actually does confuse things. "rm -r" will certainly remove a
> file as well as a directory (although not a , whereas the "Windows
> equivalent" will not. So ... Jim, we should clarify that.
Better clarify in the docs what the code actually does: if possible
without changing the code. If not possible for whatever reason, discuss
the change widely, link the docs and the Changes file to the discussion
that took place. If code is old, feelings towards a principle of least
surprise should probably be weighed in more carefully and held against
support for those who actually use this code for 20 years.
Show quoted text > The remove_tree / retree functions expect a directory. If a user's
> routine passes in a non-existent directory (or a non-directory),
> what should be the expected behavior?
Show quoted text > To me, being silent about it is far more surprising -- and could be
> really frustrating for a general user thinking it's working fine
> when it's not.
It has been that way for, err, [...let me look it up...]
Between perl-5.001n and perl-5.002 you can find this change:
commit 4633a7c4bad06b471d9310620b7fe8ddd158cccd
Author: Larry Wall <lwall@scalpel.netlabs.com>
Date: Tue Nov 21 10:01:00 1995 +1200
Unless I'm misreading things (I did not test it): since then it's
basically just the way that now has been changed.
--
andreas