On 2017-05-01 01:38:14, [email protected] wrote:
> > On 23 Jun 2015, at 15:37, Rob Hoelz (via RT) <perl6-bugs-
> > [email protected]> wrote:
> > Unlinking a non-existent file should fail() rather than return True.
>
> The end-goal of .unlinking stuff is for the file to stop existing.
> IMO that goal is achieved even if the method is called for non-
> existent files,
> so there's no failure to fail with.
Maybe I'm thinking too Unix-centric with this, but since unlink(2) raises
ENOENT when the entry doesn't exist, I think Perl 6 implementations should
reflect that behavior. A quick example for why failing on a non-existent file
should be done is let's say I'm writing data to a file and I want to clean it
up after I'm done working with it. If I create a bug that mistakenly alters
the filename, a non-failing unlink will silently succeed, but I will *think*
the file has been cleaned up. This behavior has the potential to retain
sensitive data, can go undetected for a long time, and would be non-obvious to
track down. Not every program needs this behavior, but Perl 6 has an "error by
default" policy and facilities for suppressing these errors, so I think we
should still treat unlinking a non-existent file as a failure.
> Also, this behaviour mirrors what
> Perl 5 does,
> if I recall.
Perl 5 signals failure when the file doesn't exist:
$ touch one
$ perl -le 'print unlink("one") ? 1 : 0'
1
$ perl -le 'print unlink("one") ? 1 : 0'
0
>
> I'm going to untake this ticket (as far as IO grant is concerned) and
> re-tag
> is as JVM-only issue in need to remove ability of removing directories
> from
> this method.
>
> -- IO grant