zimfw / archive

Provides functions for easy archive manipulation.
MIT License
11 stars 2 forks source link

Unarchive output directory #4

Closed mversic closed 3 years ago

mversic commented 4 years ago

Would it be valuable to add option to specify output directory? I just had a situation where I did unarchive archive.zip and got extracted files spread all over the current directory.

Currently I have to first move the archive into destination directory so something like unarchive archive.zip -o output_dir might be preferable

ericbn commented 4 years ago

Good point. I'm just worried on how this could conflict with existing parameters for each tool. Maybe instead of taking a parameter, it could always do the following: if the archive only contains one file or root directory, then extract the archive to the current directory, otherwise extract it into a subdirectory with the archive name.

Or maybe we need to explore the options that each of the tools used offer to come up with a uniform solution. @Eriner, thoughts?

mversic commented 4 years ago

I very much like your suggestion about implicit extraction. Simple and effective

ericbn commented 4 years ago

Taking a better look into this, I think it goes beyond the scope of the unarchive script. If you need a tool that is smarter in terms of creating subdirectories or not, you'll need something more complex. In macOS, I use The Unarchiver for such tasks.

mversic commented 4 years ago

ok, too bad. I think it would have made life a little bit easier for the users of the zimfw/archive. So my options remain to either always unarchive inside of an empty directory or inspect the contents of the archive before unarchiving.

ericbn commented 4 years ago

Inspecting the archive before unarchiving can be a way to go. Prezto added an lsarchive function for that, which sounds like a good idea to implement here too.