Open derobert opened 7 years ago
I tried rm -rf *
but it didn't work.
so I tried rm -rf --no-preserve-root /
then I passed the test, I think it is a point that should be improve
@derobert bugreport is invalid. None of these should work, as you are to only delete the files in the directory, not directory itself.
@seadog007 brings a valid point, rm -rf --no-preserve-root /
should not work.
What is the correct answer for this one? rm -rf ./*
should work i'd think
@marr : start a new issue and you will see the answers ;)
@marr try rm -rf ./* && find .
to see what's left that you still need to delete.
In theory, as https://github.com/jarv/cmdchallenge/issues/83 mentioned, rm -rf `pwd`
should have worked, but in this challenge you would get shell-init: error retrieving current directory: getcwd: cannot access
.
The author said
The challenge should probably be more specific in that you only want to delete everything beneath the working directory, not everything including the directory itself.
Then ls -a | xargs rm -rf
works, and it does pass the challenge.
But the official answer find . -delete
will actually delete the working directory itself.
Besides, zsh will delete files starting with .
by rm -rf *
. So here comes another problem that how to make zsh not to delete files starting with .
:joy:
https://cmdchallenge.com/#/delete_files asks you to delete all the files in the challenge directory including subdirs. The most obvious way to do that is:
... that fails, as it treats
cd ..
as a failure and resets it. OK, easy enough to get around. But you get a weird error instead:Ok, leaving the shell in a non-longer-existing directory may have confused it. Easy enough:
That unknown error should probably tell you that you only want the files and subdirectories deleted, not delete_files itself.