[clue] Unzipping zip archives with duplicates?

David L. Anselmi anselmi at anselmi.us
Wed Aug 29 08:22:08 MDT 2012


Sean LeBlanc wrote:
> In case anyone was interested, I used Ruby to do this.

Thanks, I'm interested.

> Ultimately, it will most likely be launched by Ant - modern versions now
> support a "script" task that utilizes Apache's BSF which implements
> JSR-223 - which means that with the JRuby jar, I can run Ruby within Ant
> without shelling out. This is so I don't have to write all the crufty
> Ant stuff to detect OS version, and then try to either guess where the
> ruby binary might be installed or what shell to launch....bash or
> cmd...which is a long way of saying "this is why there isn't a shebang
> at the top of the script".

I don't know much about that, but doesn't Ruby just do the right thing?  I'd guess that if you use 
back ticks in perl it would get the right interpreter on both Linux and Windows.  Although you don't 
seem to use any of that in your script.

Do the files in the zip have paths?  If not I'm not sure why you have 2 loops to figure out the 
version number.

In perl I'd have made each path a hash key and incremented the value each time.  Then you shouldn't 
need to check whether something exists--if it's in the hash you use the value as the version number 
and if it isn't you use it as is.

I didn't look at perl's zip library so I'd have used unzip to get the list of files and do the 
unzipping, so you're more elegant there.

And looking a little closer, would unzip -B have done what you need?

Dave


More information about the clue mailing list