arfoll / unrarall

bash script to unrar everything and cleanup in a given directory
GNU General Public License v3.0
261 stars 68 forks source link

Allow overriding default "find" binary #14

Closed strayer closed 7 years ago

strayer commented 10 years ago

I had to do this because the default find utility on my Synology NAS is a busybox function that is missing -iregex - installing findutils via the package manager ipkg doesn't override the default and creates a findutils-find executable instead.

I'm note sure if you want this in the code since this probably won't affect many users, just close the pull request if you don't want it. It is mostly copy and paste from the UNRAR_BINARIES stuff.

arfoll commented 10 years ago

Thanks for hacking on unrarall! This is a very good point, busybox based NAS are very common and it seems busybox does not support -iregex at all - no matter what flags it's compiled with :(. I'm however not sure I like your patch, here's what I'd rather do:

If you're interested in submitting something like this I'd love to add it :)

Also I tried for a while trying to add regex modifiers to "find -regex" but ?i and /i don't seem to work... so I guess that's a no go.

delcypher commented 10 years ago

@arfoll What's python support like on most 'NAS's? If it's generally supported I'd be very tempted to rewrite unrarall in python. I'd say my python skills are at a point now where I could do it pretty easily. I think the code would also be a lot cleaner in python. The regex issues also go a way because we can just use the python standard library to replace everything we current use find to do.

strayer commented 10 years ago

Well, in case of my Synology DS207+ with Synology DSM 3.1 it doesn't have Python built-in, but the DS207+ is pretty old. Perl 5.8.6 and PHP 5.3.3 are included though. I think DSM 4 is the most recent version available for newer hardware of Synology.

Another way would be to implement a fallback utilizing Perl, I guess nearly every system of the last 10 years would include Perl support. To be fair, DSM 3.1 doesn't even include bash as far as I could see, I had to install it manually with ipkg. I didn't try running unrarall with the busybox sh though.

arfoll commented 10 years ago

@delcypher All the NAS boxes I've worked on (which to be fair isn't that many) have some amount of python on as default but hide it away in an obscure dir. I think one of the cool things about unrarall is the fact it has very low requirements so I'd rather avoid rewriting it in python even if libarchive looks so sweet :) Also maintaining such a bash script is funny! I think have our users are random people that just copy the script in /usr/bin/ and are like "wey it works".

@Strayer It's normal for embedded boxes like NAS not to include bash, it's GPLv3 (unless you go back to bash 3) and busybox is much much smaller. It's unlikely we'd run all that well on busybox sh, although would be fun to try!

Falling back to perl for regex isn't necesarily a bad idea but I still thing the easiest is to test for -iregex support and fall back to -regex. We could also do this by detecting we are using binaries from busybox, which probably isn't hard to do (check symlinks to busybox from which find).

delcypher commented 7 years ago

This is superseded by ae74563b92c761e8553da4cd357b3024e4eaf9e0 and 02601c14af5eb58f86af3deaf2b0d587b93e0628