New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unlink does not signal failures / [JVM] .IO.unlink succeeds in unlinking empty directories #4340
Comments
From @hoelzroUnlinking a non-existent file should fail() rather than return True. |
From @lizmat
To expand on this: it appears that on MoarVM nqp::unlink returns the filename regardless of whether successful or not. On the JVM, it appears to return 0 for success, and -2 for non-existing file, and throws an exception if it could not remove the file for some reason. It also seems capable of removing empty directories on the JVM (on MoarVM it fails with an exception). Liz |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznet
The end-goal of .unlinking stuff is for the file to stop existing. I'm going to untake this ticket (as far as IO grant is concerned) and re-tag -- IO grant |
From @hoelzroOn 2017-05-01 01:38:14, cpan@zoffix.com wrote:
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.
Perl 5 signals failure when the file doesn't exist: $ touch one
|
From sidhekin@gmail.comOn Mon, May 1, 2017 at 6:25 PM, Rob Hoelz via RT <
Not exactly. Perl5 unlink is documented to return the number of files $ touch one; touch two No failure signalled … Eirik |
From @zoffixznetOn Mon, 01 May 2017 10:05:41 -0700, sidhekin@gmail.com wrote:
It rudimentary way it is; you can still write: `die "Some failure" unless @files == unlink @files` In Perl 6 it doesn't, and I see our &unlink even returns the full original list of files, despite some non-existing, which is certainly LTA. *clicks "Take" button again* |
It looks like the issue on the JVM backend has been fixed a while ago (Raku/nqp@3921b1e6c7). As the commit message mentions there is a spectest for this behaviour:
So, this issue is only about whether unlinking a non-existent file should signal failure:
Edited: I don't have the permissions to remove the reference to the solved JVM problem ( |
Migrated from rt.perl.org#125463 (status was 'open')
Searchable as RT125463$
The text was updated successfully, but these errors were encountered: