I get bad substitutions and '+=1' errors; will attach a patch that should make it sh compatible.
Created attachment 166253 [details, diff] sh patch
Created attachment 166255 [details, diff] sh patch bis seems I messed up fixing the += one.
Thanks for the patch. I think next time only say us that you did the fix. And commit it yourself. It will be faster :]