transistor1 / shellista

shellista - iOS shell written for Pythonista
https://omz-forums.appspot.com/pythonista/post/5302343285342208
78 stars 18 forks source link

rm -r option should be required for recursive delete #29

Open jsbain opened 10 years ago

jsbain commented 10 years ago

Fat fingered an extra period today in my Documents folder... rm. somefile I noticed the extra period, noticed it was taking a while, so cancelled the script. At that point, about half of the folders, etc under my main directory had been removed!

I'm thinking rm ., rm .., or for that matter deleting any folder on the current fully expanded path should be disallowed.

I think in real bash, you'd have to do rm -r to recursively delete. We may want to modify rm this way to be a little safer...

briarfox commented 10 years ago

jsbain, good catch. the rm used is from the original shelista. How about rm will only remove a single file. To remove everything from a directory and/or subdirectories -r flag will be required.

briarfox commented 10 years ago

@jsbain I forgot to reload the module after making changes which resulted in deleting my Documents folder.

jsbain commented 10 years ago

Lol, oh no!

briarfox commented 10 years ago

Should be fixed if you re download shellista-core

briarfox commented 10 years ago

Added argparse and -r -v -f flags to core rm_plugin.py. The default of rm will remove a single file and ask for confirmation. The -r flag will recursively remove directories. The -f flag will ignore confirmation. -v will show output in console.

Could someone please test this?