jarv / cmdchallenge

This repo is mirror of https://gitlab.com/jarv/cmdchallenge
https://about.cmdchallenge.com
MIT License
721 stars 71 forks source link

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

Open derobert opened 7 years ago

derobert commented 7 years ago

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.

seadog007 commented 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

0ki commented 7 years ago

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

marr commented 7 years ago

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

avioli commented 7 years ago

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

branning commented 7 years ago

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

imba-tjd commented 6 years ago

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: