cmdchallenge icon indicating copy to clipboard operation
cmdchallenge copied to clipboard

delete_files doesn't like it if you rm -Rf delete_files

Open derobert opened this issue 7 years ago • 6 comments

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:

cd ..
rm -Rf delete_files

... 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:

bash(0)> rm -Rf ../delete_files
Unknown Error :(
bash(☠️)>  

Ok, leaving the shell in a non-longer-existing directory may have confused it. Easy enough:

bash(0)> cd .. && rm -Rf delete_files
Unknown Error :(
bash(☠️)>  

That unknown error should probably tell you that you only want the files and subdirectories deleted, not delete_files itself.

derobert avatar Feb 02 '17 21:02 derobert

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

seadog007 avatar Feb 03 '17 01:02 seadog007

@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.

0ki avatar Feb 03 '17 04:02 0ki

What is the correct answer for this one? rm -rf ./* should work i'd think

marr avatar Feb 03 '17 20:02 marr

@marr : start a new issue and you will see the answers ;)

avioli avatar Feb 03 '17 23:02 avioli

@marr try rm -rf ./* && find . to see what's left that you still need to delete.

branning avatar Feb 05 '17 05:02 branning

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:

imba-tjd avatar Jul 22 '18 09:07 imba-tjd